Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.

Commit f59ecba

Browse files
committed
fix product.variants.unscoped call finding variants outside of the product scope
1 parent 5938f71 commit f59ecba

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/spree/wombat/handler/product_handler_base.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,9 @@ def process_child_products(product, children)
123123
child_product[:options] = option_type_values.collect {|k,v| {name: k, value: v} }
124124
child_product[:price] = price
125125

126-
variant = product.variants.unscoped.find_by_sku(child_product[:sku])
126+
variant = Spree::Variant.unscoped.where(sku: child_product[:sku], product: product).first_or_initialize
127+
variant.update_attributes!(child_product)
127128

128-
if variant
129-
variant.update_attributes(child_product)
130-
else
131-
variant = product.variants.create!({ product: product }.merge(child_product))
132-
end
133129
process_images(variant, images)
134130
end
135131
end

0 commit comments

Comments
 (0)