Skip to content

Commit

Permalink
Show Unique Variants regardless of stock location
Browse files Browse the repository at this point in the history
  • Loading branch information
mayanktap committed Jan 30, 2019
1 parent 51eae53 commit 4b5f2d6
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 4b5f2d6

Please sign in to comment.