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
Fixed N+1s with `purchasable?`/`in_stock?` Product methods
Damian Legawiec199ecf543dcc
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex 423d0d49e8..d771203bbe 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -290,12 +290,12 @@ module Spree# Can't use short form block syntax due to https://github.com/Netflix/fast_jsonapi/issues/259def purchasable?- @purchasable ||= default_variant.purchasable? || variants.in_stock_or_backorderable.any?+ @purchasable ||= default_variant.purchasable? || variants.any?(&:purchasable?)end# Can't use short form block syntax due to https://github.com/Netflix/fast_jsonapi/issues/259def in_stock?- @in_stock ||= default_variant.in_stock? || variants.in_stock.any?+ @in_stock ||= default_variant.in_stock? || variants.any?(&:in_stock?)end# Can't use short form block syntax due to https://github.com/Netflix/fast_jsonapi/issues/259