Permalink
Browse files

image associate with variants

  • Loading branch information...
1 parent 19cc8b2 commit 2b81caf0c18b1b3ff16af820ef662a01f0c2d3ba @libkazz committed Oct 1, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 app/models/product_import.rb
@@ -188,7 +188,7 @@ def create_product_using(params_hash)
#Finally, attach any images that have been specified
IMPORT_PRODUCT_SETTINGS[:image_fields].each do |field|
- find_and_attach_image_to(product, params_hash[field.to_sym])
+ find_and_attach_image_to(product.master, params_hash[field.to_sym])
end
if IMPORT_PRODUCT_SETTINGS[:multi_domain_importing] && product.respond_to?(:stores)
@@ -256,10 +256,10 @@ def find_and_attach_image_to(product_or_variant, filename)
file = filename =~ /\Ahttp[s]*:\/\// ? fetch_remote_image(filename) : fetch_local_image(filename)
#An image has an attachment (the image file) and some object which 'views' it
product_image = Image.new({:attachment => file,
- :viewable => product_or_variant,
:position => product_or_variant.images.length
})
+ product_image.viewable = product_or_variant
product_or_variant.images << product_image if product_image.save
end

0 comments on commit 2b81caf

Please sign in to comment.