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
Use parameterized property name during creation, added `Product#remov… (#12170)
Damian Legawiecf2be12398f98
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex bdeeabf010..edc2229de4 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -363,10 +363,15 @@ module Spreeenddef property(property_name)- product_properties.joins(:property).find_by(Property.table_name => { name: property_name }).try(:value)+ if product_properties.loaded?+ product_properties.detect { |property| property.property.name == property_name }.try(:value)+ else+ product_properties.joins(:property).find_by(spree_properties: { name: property_name }).try(:value)+ endenddef set_property(property_name, property_value, property_presentation = property_name)+ property_name = property_name.to_s.parameterizeApplicationRecord.transaction do# Manual first_or_create to work around Mobility bugproperty = if Property.where(name: property_name).exists?@@ -381,7 +386,7 @@ module Spreeproduct_property = if ProductProperty.where(product: self, property: property).exists?ProductProperty.where(product: self, property: property).firstelse- ProductProperty.create(product: self, property: property)+ ProductProperty.new(product: self, property: property)endproduct_property.value = property_value@@ -389,6 +394,10 @@ module Spreeendend+ def remove_property(property_name)+ product_properties.joins(:property).find_by(spree_properties: { name: property_name.parameterize })&.destroy+ end+def total_on_hand@total_on_hand ||= if any_variants_not_track_inventory?BigDecimal::INFINITY