app/models/spree/product_import.rb
# find_and_attach_image_to
# This method attaches images to products. The images may come
# from a local source (i.e. on disk), or they may be online (HTTP/HTTPS).
find_and_attach_image_to
This method attaches images to products. The images may come
from a local source , or they may be online (HTTP/HTTPS).
find_and_attach_image_to This method attaches images to products . The images may come from a local source or they may be online ( HTTP / HTTPS ) .
def find_and_attach_image_to(product_or_variant, filename)
      return if filename.blank?
      file = filename =~ /\Ahttp[s]*:\/\// ? fetch_remote_image(filename) : fetch_local_image(filename)
      product_image = Spree::Image.new({:attachment => file,
                                :viewable_id => product_or_variant.id,
                                :viewable_type => "Spree::Variant",
                                :position => product_or_variant.images.length+1
                                })
      log("#{product_image.viewable_id} : #{product_image.viewable_type} : #{product_image.position}")
      product_or_variant.images << product_image if product_image.save
    end
def find_and_attach_image_to ( product_or_variant , filename ) return if filename . blank? file = filename =~ / \A http[s]*: \/ \/ / ? fetch_remote_image ( filename ) : fetch_local_image ( filename ) product_image = Spree :: Image . new ( { :attachment => file , :viewable_id => product_or_variant . id , :viewable_type => "Spree::Variant" , :position => product_or_variant . images . length + 1 } ) log ( "#{product_image.viewable_id} : #{product_image.viewable_type} : #{product_image.position}" ) product_or_variant . images << product_image if product_image . save end
find_and_attach_image_to
This method attaches images to products.
find_and_attach_image_to This method attaches images to products .
#The image can be fetched from an HTTP or local source - either method returns a Tempfile #An image has an attachment (the image file) and some object which 'views' it
product_or_variant
<not_specific>
filename
<not_specific>