Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

correct Option Value scopes

Łukasz Adamczyk1bcbb77c971e
diff --git a/core/app/models/spree/option_value.rb b/core/app/models/spree/option_value.rb
index 398b9d9251..12dd1fb3af 100644
--- a/core/app/models/spree/option_value.rb
+++ b/core/app/models/spree/option_value.rb
@@ -12,12 +12,15 @@ module Spree
end
scope :filterable, lambda {
- joins(:option_type, :variants).
+ joins(:option_type).
where(OptionType.table_name => { filterable: true }).
distinct
}
- scope :for_products, ->(products) { where(Variant.table_name => { product_id: products.map(&:id) }) }
+ scope :for_products, lambda { |products|
+ joins(:variants).
+ where(Variant.table_name => { product_id: products.map(&:id) })
+ }
after_touch :touch_all_variants