Sha256: d81812c0abe6a7e63a4e1d6f82f3938aafb1476abbfce963a73db997aa28733f

Contents?: true

Size: 917 Bytes

Versions: 10

Compression:

Stored size: 917 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.split(' ').join('_'))})"
          end
        end
      end

      # return cached full name
      @fname
    end


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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
magerecord-0.4.0 lib/magerecord/fitlion/product.rb
magerecord-0.3.1 lib/magerecord/fitlion/product.rb
magerecord-0.3.0 lib/magerecord/fitlion/product.rb
magerecord-0.2.2 lib/magerecord/fitlion/product.rb
magerecord-0.2.1 lib/magerecord/fitlion/product.rb
magerecord-0.2.0 lib/magerecord/fitlion/product.rb
magerecord-0.1.12 lib/magerecord/fitlion/product.rb
magerecord-0.1.10 lib/magerecord/fitlion/product.rb
magerecord-0.1.9 lib/magerecord/fitlion/product.rb
magerecord-0.1.8 lib/magerecord/fitlion/product.rb