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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Improve performance of `Product#for_store` scope (#11516)
Damian Legawiec4b7f668222e3
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex 17031fcb74..35f8a6ce90 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -120,6 +120,8 @@ module Spreevalidates :slug, presence: true, uniqueness: { allow_blank: true, case_sensitive: true, scope: spree_base_uniqueness_scope }validate :discontinue_on_must_be_later_than_available_on, if: -> { available_on && discontinue_on }+ scope :for_store, ->(store) { joins(:store_products).where(StoreProduct.table_name => { store_id: store.id }) }+attr_accessor :option_values_hashaccepts_nested_attributes_for :product_properties, allow_destroy: true, reject_if: ->(pp) { pp[:property_name].blank? }