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
Avoid creating instances of objects when we only need their IDs
Damian Legawieca49db7cd19f6
diff --git a/api/app/controllers/spree/api/v1/taxons_controller.rb b/api/app/controllers/spree/api/v1/taxons_controller.rbindex ce06c92766..e93b1866a7 100644--- a/api/app/controllers/spree/api/v1/taxons_controller.rb+++ b/api/app/controllers/spree/api/v1/taxons_controller.rb@@ -37,7 +37,7 @@ module Spreeinvalid_resource!(@taxon) and returnend- @taxon.parent_id = taxonomy.root.id unless params[:taxon][:parent_id]+ @taxon.parent_id = taxonomy.root_id unless params[:taxon][:parent_id]if @taxon.saverespond_with(@taxon, status: 201, default_template: :show)diff --git a/backend/app/controllers/spree/admin/images_controller.rb b/backend/app/controllers/spree/admin/images_controller.rbindex 7d8ffb2c6b..b4782b4a82 100644--- a/backend/app/controllers/spree/admin/images_controller.rb+++ b/backend/app/controllers/spree/admin/images_controller.rb@@ -26,7 +26,7 @@ module Spree@variants = @product.variants.map do |variant|[variant.sku_and_options_text, variant.id]end- @variants.insert(0, [Spree.t(:all), @product.master.id])+ @variants.insert(0, [Spree.t(:all), @product.master_id])enddef set_viewablediff --git a/backend/app/controllers/spree/admin/orders/customer_details_controller.rb b/backend/app/controllers/spree/admin/orders/customer_details_controller.rbindex eb20467e1d..37cd29c882 100644--- a/backend/app/controllers/spree/admin/orders/customer_details_controller.rb+++ b/backend/app/controllers/spree/admin/orders/customer_details_controller.rb@@ -11,7 +11,7 @@ module Spreeenddef edit- country_id = Address.default.country.id+ country_id = Address.default.country_id@order.build_bill_address(country_id: country_id) if @order.bill_address.nil?@order.build_ship_address(country_id: country_id) if @order.ship_address.nil?diff --git a/core/app/models/spree/promotion/rules/option_value.rb b/core/app/models/spree/promotion/rules/option_value.rbindex 1d9da28914..109a349b6c 100644--- a/core/app/models/spree/promotion/rules/option_value.rb+++ b/core/app/models/spree/promotion/rules/option_value.rb@@ -31,7 +31,7 @@ module Spreeenddef actionable?(line_item)- product_id = line_item.product.id+ product_id = line_item.product_idoption_values_ids = line_item.variant.option_value_idseligible_product_ids = preferred_eligible_values.keyseligible_value_ids = preferred_eligible_values[product_id]diff --git a/core/app/services/spree/cart/estimate_shipping_rates.rb b/core/app/services/spree/cart/estimate_shipping_rates.rbindex f890c91ac7..9c624ba089 100644--- a/core/app/services/spree/cart/estimate_shipping_rates.rb+++ b/core/app/services/spree/cart/estimate_shipping_rates.rb@@ -24,7 +24,7 @@ module Spreeif country_iso.present?::Spree::Country.by_iso(country_iso)&.idelse- ::Spree::Country.default.id+ Spree::Config[:default_country_id]endenddiff --git a/core/lib/spree/testing_support/factories/stock_location_factory.rb b/core/lib/spree/testing_support/factories/stock_location_factory.rbindex 8384ae4751..1631ad41cb 100644--- a/core/lib/spree/testing_support/factories/stock_location_factory.rb+++ b/core/lib/spree/testing_support/factories/stock_location_factory.rb@@ -20,8 +20,8 @@ FactoryBot.define doproduct_1 = create(:product)product_2 = create(:product)- stock_location.stock_items.where(variant_id: product_1.master.id).first.adjust_count_on_hand(10)- stock_location.stock_items.where(variant_id: product_2.master.id).first.adjust_count_on_hand(20)+ stock_location.stock_items.where(variant_id: product_1.master_id).first.adjust_count_on_hand(10)+ stock_location.stock_items.where(variant_id: product_2.master_id).first.adjust_count_on_hand(20)endendend