Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2868: Products at multiple Stock Locations appear as unique variants #3063

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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