Class: Spree::FeedProduct
- Inherits:
-
Object
- Object
- Spree::FeedProduct
- Defined in:
- app/models/spree/feed_product.rb
Instance Attribute Summary collapse
-
#product ⇒ Object
readonly
Returns the value of attribute product.
Instance Method Summary collapse
- #availability ⇒ Object
- #brand ⇒ Object
- #category ⇒ Object
-
#condition ⇒ Object
Must be “new”, “refurbished”, or “used”.
- #image_link ⇒ Object
-
#initialize(product) ⇒ FeedProduct
constructor
A new instance of FeedProduct.
- #link ⇒ Object
- #mpn ⇒ Object
- #price ⇒ Object
- #schema ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(product) ⇒ FeedProduct
Returns a new instance of FeedProduct.
7 8 9 |
# File 'app/models/spree/feed_product.rb', line 7 def initialize(product) @product = product end |
Instance Attribute Details
#product ⇒ Object (readonly)
Returns the value of attribute product.
5 6 7 |
# File 'app/models/spree/feed_product.rb', line 5 def product @product end |
Instance Method Details
#availability ⇒ Object
54 55 56 |
# File 'app/models/spree/feed_product.rb', line 54 def availability product.master.in_stock? ? 'in stock' : 'out of stock' end |
#brand ⇒ Object
58 |
# File 'app/models/spree/feed_product.rb', line 58 def brand; end |
#category ⇒ Object
64 65 66 |
# File 'app/models/spree/feed_product.rb', line 64 def category # Must be selected from https://support.google.com/merchants/answer/1705911 end |
#condition ⇒ Object
Must be “new”, “refurbished”, or “used”.
46 47 48 |
# File 'app/models/spree/feed_product.rb', line 46 def condition "new" end |
#image_link ⇒ Object
39 40 41 42 43 |
# File 'app/models/spree/feed_product.rb', line 39 def image_link return unless product.images.any? product.images.first..url(:large) end |
#link ⇒ Object
35 36 37 |
# File 'app/models/spree/feed_product.rb', line 35 def link ->(view) { view.product_url(product) } end |
#mpn ⇒ Object
60 61 62 |
# File 'app/models/spree/feed_product.rb', line 60 def mpn product.master.sku end |
#price ⇒ Object
50 51 52 |
# File 'app/models/spree/feed_product.rb', line 50 def price Spree::Money.new(product.price).money.format(symbol: false, with_currency: true) end |
#schema ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/spree/feed_product.rb', line 11 def schema { 'g:id' => id, 'title' => title, 'description' => description, 'link' => link, 'g:image_link' => image_link, 'g:condition' => condition, 'g:price' => price, 'g:availability' => availability, 'g:brand' => brand, 'g:mpn' => mpn, 'category' => category, } end |
#title ⇒ Object
29 30 31 |
# File 'app/models/spree/feed_product.rb', line 29 def title product.name end |