From 197bf09be1d54e9b1f8d4074a0f7cc56b0c60e76 Mon Sep 17 00:00:00 2001 From: Yudi Fu Date: Thu, 22 Oct 2015 16:17:26 -0700 Subject: [PATCH] Check if stock_item exists before adding variant to stock_location --- app/models/spree/product_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 89134f8..42ed289 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -24,7 +24,7 @@ def populate_for_supplier!(supplier) variants_including_master.each do |variant| unless variant.suppliers.pluck(:id).include?(supplier.id) variant.suppliers << supplier - supplier.stock_locations.each { |location| location.propagate_variant(variant) } + supplier.stock_locations.each { |location| location.set_up_stock_item(variant) } end end end