Skip to content

armgit / spree

Public Imported from GitHub
0

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.

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.rb
index 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 Spree
invalid_resource!(@taxon) and return
end
- @taxon.parent_id = taxonomy.root.id unless params[:taxon][:parent_id]
+ @taxon.parent_id = taxonomy.root_id unless params[:taxon][:parent_id]
if @taxon.save
respond_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.rb
index 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])
end
def set_viewable
diff --git a/backend/app/controllers/spree/admin/orders/customer_details_controller.rb b/backend/app/controllers/spree/admin/orders/customer_details_controller.rb
index 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 Spree
end
def 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.rb
index 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 Spree
end
def actionable?(line_item)
- product_id = line_item.product.id
+ product_id = line_item.product_id
option_values_ids = line_item.variant.option_value_ids
eligible_product_ids = preferred_eligible_values.keys
eligible_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.rb
index 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 Spree
if country_iso.present?
::Spree::Country.by_iso(country_iso)&.id
else
- ::Spree::Country.default.id
+ Spree::Config[:default_country_id]
end
end
diff --git a/core/lib/spree/testing_support/factories/stock_location_factory.rb b/core/lib/spree/testing_support/factories/stock_location_factory.rb
index 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 do
product_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)
end
end
end