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
Fallback to old solution for propagating stock items
Damian Legawiec15c69bda810f
diff --git a/core/app/models/spree/stock_location.rb b/core/app/models/spree/stock_location.rbindex c04071102a..071bd77aaf 100644--- a/core/app/models/spree/stock_location.rb+++ b/core/app/models/spree/stock_location.rb@@ -107,18 +107,25 @@ module Spreedef create_stock_itemsvariants_scope = Spree::Variant- prepared_stock_items = variants_scope.ids.map do |variant_id|- Hash[- 'stock_location_id', id,- 'variant_id', variant_id,- 'backorderable', backorderable_default,- 'created_at', Time.current,- 'updated_at', Time.current- ]- end- if prepared_stock_items.any?- stock_items.insert_all(prepared_stock_items)- variants_scope.touch_all++ if self.class.method_defined?(:insert_all) && self.class.method_defined?(:touch_all)+ prepared_stock_items = variants_scope.ids.map do |variant_id|+ Hash[+ 'stock_location_id', id,+ 'variant_id', variant_id,+ 'backorderable', backorderable_default,+ 'created_at', Time.current,+ 'updated_at', Time.current+ ]+ end+ if prepared_stock_items.any?+ stock_items.insert_all(prepared_stock_items)+ variants_scope.touch_all+ end+ else+ variants_scope.find_each do |variant|+ propagate_variant(variant)+ endendend