Sha256: 72af3f3ea525017803a95986e552831d97c1fd02a20d69752d953f55ffa3a86d

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 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(/^.*\((\w*)(?: only)?\)/, "\\1").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

2 entries across 2 versions & 1 rubygems

Version Path
magerecord-0.1.1 lib/magerecord/fitlion/product.rb
magerecord-0.1.0 lib/magerecord/fitlion/product.rb