Sha256: d48671792ccfbf3e6b030b5e5b94c38d9cc3af4f6ef633782e907d72812d0156

Contents?: true

Size: 896 Bytes

Versions: 5

Compression:

Stored size: 896 Bytes

Contents

module MageRecord
  # add custom FitLion-specific product methods
  class Product < EavRecord
    def uom
      "#{measurement} #{unit}"
    end


    def full_name
      if @fname.nil?
        @fname = "#{name} (#{uom})"

        # note: most bundles are not associated with any brand
        if brand
          @fname = "(#{brand}) #{@fname}"
        end

        # only simple/virtual products will have custom attributes
        if %w{simple virtual}.include?(type_id)
          # get all custom product attributes specific to attribute set
          attribs = set.downcase.gsub(/.*\((.+)\)/, "\\1").gsub(/ only/, '').split(' + ') - ['brand']

          attribs.each do |attr|
            @fname += " (#{send(attr)})"
          end
        end
      end

      # return cached full name
      @fname
    end


    def is_supplement?
      set.downcase.include? 'supplement'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
magerecord-0.1.6 lib/magerecord/fitlion/product.rb
magerecord-0.1.5 lib/magerecord/fitlion/product.rb
magerecord-0.1.4 lib/magerecord/fitlion/product.rb
magerecord-0.1.3 lib/magerecord/fitlion/product.rb
magerecord-0.1.2 lib/magerecord/fitlion/product.rb