Class: ShopProductVariant
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ShopProductVariant
- Defined in:
- app/models/shop_product_variant.rb
Instance Method Summary collapse
-
#price ⇒ Object
Returns the price of the variant plus the product price.
-
#sku ⇒ Object
Returns a mixed sku of product and variant name.
-
#slug ⇒ Object
Returns slug of the product.
- #to_param ⇒ Object
- #url ⇒ Object
Instance Method Details
#price ⇒ Object
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 |
#sku ⇒ Object
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 |
#slug ⇒ Object
Returns slug of the product
32 33 34 |
# File 'app/models/shop_product_variant.rb', line 32 def slug product.slug end |
#to_param ⇒ Object
40 41 42 |
# File 'app/models/shop_product_variant.rb', line 40 def to_param product.to_param end |
#url ⇒ Object
36 37 38 |
# File 'app/models/shop_product_variant.rb', line 36 def url product.url end |