Skip to content

Commit

Permalink
Merge pull request #3063 from mayanktap/remove_duplicate_variants
Browse files Browse the repository at this point in the history
Issue 2868: Products at multiple Stock Locations appear as unique variants
  • Loading branch information
kennyadsl authored Jan 31, 2019
2 parents a7e2c6d + 4b5f2d6 commit b5d6ae7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def self.suppliable
Spree::StockItem.arel_table[:count_on_hand].gt(0),
Spree::StockItem.arel_table[:backorderable].eq(true)
]
joins(:stock_items).where(arel_conditions.inject(:or))
joins(:stock_items).where(arel_conditions.inject(:or)).distinct
end

self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
Expand Down
4 changes: 4 additions & 0 deletions core/spec/models/spree/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@
expect( subject ).not_to include(out_of_stock_variant)
end

it "includes variants only once" do
expect(subject.to_a.count(in_stock_variant)).to be 1
end

context "inventory levels globally not tracked" do
before { Spree::Config.track_inventory_levels = false }

Expand Down

0 comments on commit b5d6ae7

Please sign in to comment.