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
Remove some product methods memoization, add default_image and secondary_image to memoized methods const
Łukasz Adamczyk13aab30b48e2
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex 0dd64d784a..21d19f6e24 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -34,6 +34,7 @@ module SpreeMEMOIZED_METHODS = %w[total_on_hand taxonomy_ids taxon_and_ancestors categorydefault_variant_id tax_category default_variant+ default_image secondary_imagepurchasable? in_stock? backorderable? has_variants?]STATUS_TO_WEBHOOK_EVENT = {@@ -399,29 +400,29 @@ module Spreeattr_accessor :prototype_iddef first_or_default_variant(currency)- @first_or_default_variant ||= if !has_variants?- default_variant- elsif first_available_variant(currency).present?- first_available_variant(currency)- else- variants.first- end+ if !has_variants?+ default_variant+ elsif first_available_variant(currency).present?+ first_available_variant(currency)+ else+ variants.first+ endenddef first_available_variant(currency)- @first_available_variant ||= variants.find { |v| v.purchasable? && v.price_in(currency).amount.present? }+ variants.find { |v| v.purchasable? && v.price_in(currency).amount.present? }enddef price_varies?(currency)- @price_varies ||= prices_including_master.find_all { |p| p.currency == currency && p.amount.present? }.map(&:amount).uniq.count > 1+ prices_including_master.find_all { |p| p.currency == currency && p.amount.present? }.map(&:amount).uniq.count > 1enddef any_variant_available?(currency)- @any_variant_available ||= if has_variants?- first_available_variant(currency).present?- else- master.purchasable? && master.price_in(currency).amount.present?- end+ if has_variants?+ first_available_variant(currency).present?+ else+ master.purchasable? && master.price_in(currency).amount.present?+ endend# returns the lowest price for the product in the given currency