Class: ShopProductVariant

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/shop_product_variant.rb

Instance Method Summary collapse

Instance Method Details

#priceObject

Returns the price of the variant plus the product price



18
19
20
21
22
23
24
# File 'app/models/shop_product_variant.rb', line 18

def price
  price = product.price
  if read_attribute(:price).present?
    price = read_attribute(:price) + product.price
  end
  price
end

#skuObject

Returns a mixed sku of product and variant name



27
28
29
# File 'app/models/shop_product_variant.rb', line 27

def sku
  %{#{product.sku}-#{ShopProduct.to_sku(name)}}
end

#slugObject

Returns slug of the product



32
33
34
# File 'app/models/shop_product_variant.rb', line 32

def slug
  product.slug
end

#to_paramObject



40
41
42
# File 'app/models/shop_product_variant.rb', line 40

def to_param
  product.to_param
end

#urlObject



36
37
38
# File 'app/models/shop_product_variant.rb', line 36

def url
  product.url
end