lib/loaders/spree/image_loader.rb
# Over ride base class process with some Spree::Image specifics
#
# What process a value string from a column, assigning value(s) to correct association on Product.
# Method map represents a column from a file and it's correlated Product association.
# Value string which may contain multiple values for a collection (has_many) association.
#
Over ride base class process with some Spree::Image specifics
What process a value string from a column, assigning value(s) to correct association on Product.
Method map represents a column from a file and it's correlated Product association.
Value string which may contain multiple values for a collection (has_many) association.
Over ride base class process with some Spree :: Image specifics What process a value string from a column assigning value ( s ) to correct association on Product . Method map represents a column from a file and it ' s correlated Product association . Value string which may contain multiple values for a collection ( has_many ) association .
def process(method_detail, value)  
        raise ImageLoadError.new("Cannot process #{value} NO details found to assign to") unless(method_detail)
        current_value, current_attribute_hash = @populator.prepare_data(method_detail, value)
        operator = method_detail.operator
        if(current_value && ImageLoader::acceptable_path_headers.include?(operator) )
          add_images( @load_object ) if(@load_object)
        elsif(current_value && method_detail.operator )    
          if( MethodDictionary::find_method_detail_if_column(@@product_klass, operator) )
            @load_object = get_record_by(@@product_klass, operator, current_value)
          elsif( MethodDictionary::find_method_detail_if_column(@@variant_klass, operator) )
            puts "Find VARIANT with  #{operator} == #{current_value}"
            @load_object = get_record_by(@@variant_klass, operator, current_value)
          else
            raise "No Spree class can be searched for by #{operator}"
          end  
          unless(@load_object)
            puts "WARNING: Could not find a record where #{operator} == #{current_value}"
            return
          else
            puts "Image Attachment on record #{@load_object.inspect}"
          end
        end
      end
def process ( method_detail , value ) raise ImageLoadError . new ( "Cannot process #{value} NO details found to assign to" ) unless ( method_detail ) current_value , current_attribute_hash = @populator . prepare_data ( method_detail , value ) operator = method_detail . operator if ( current_value && ImageLoader :: acceptable_path_headers . include? ( operator ) ) add_images ( @load_object ) if ( @load_object ) elsif ( current_value && method_detail . operator ) if ( MethodDictionary :: find_method_detail_if_column ( @@product_klass , operator ) ) @load_object = get_record_by ( @@product_klass , operator , current_value ) elsif ( MethodDictionary :: find_method_detail_if_column ( @@variant_klass , operator ) ) puts "Find VARIANT with  #{operator} == #{current_value}" @load_object = get_record_by ( @@variant_klass , operator , current_value ) else raise "No Spree class can be searched for by #{operator}" end unless ( @load_object ) puts "WARNING: Could not find a record where #{operator} == #{current_value}" return else puts "Image Attachment on record #{@load_object.inspect}" end end end
Over ride base class process with some Spree::Image specifics
What process a value string from a column, assigning value(s) to correct association on Product.
Over ride base class process with some Spree :: Image specifics What process a value string from a column assigning value ( s ) to correct association on Product .
# TODO - start supporting assigning extra data via current_attribute_hash # TODO - current relies on correct order - i.e lookup column must come before attachment # find the db record to assign our Image usually expect either SKU (Variant) or Name (product)
method_detail
value