Class: Workarea::Storefront::GoogleProductFeedViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Storefront::GoogleProductFeedViewModel
- Includes:
- ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper
- Defined in:
- app/view_models/workarea/storefront/google_product_feed_view_model.rb
Defined Under Namespace
Modules: ProductImageUrl
Class Method Summary collapse
Instance Method Summary collapse
- #brand ⇒ Object
- #category_name ⇒ Object
-
#image ⇒ Object
TODO this should be changed to return sku images if present.
- #meta_description ⇒ Object
- #product_type ⇒ Object
- #sku_price(sku) ⇒ Object
- #variants ⇒ Object
Class Method Details
.fields ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 18 def self.fields [ 'item_group_id', 'id', 'title', 'description', 'link', 'image_link', 'availability', 'condition', 'brand', 'color', 'size', 'google_product_category', 'product_type', 'price' ] + GoogleProductFeed.static_feed_values.keys end |
Instance Method Details
#brand ⇒ Object
39 40 41 42 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 39 def brand return '' unless model.filters['brand'].present? model.filters['brand'].join(' ') end |
#category_name ⇒ Object
44 45 46 47 48 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 44 def category_name model.google_category.presence || category&.google_name.presence || Workarea::GoogleProductFeed.default_category end |
#image ⇒ Object
TODO this should be changed to return sku images if present
51 52 53 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 51 def image ProductImageUrl.product_image_url(images.primary, GoogleProductFeed.image_size) end |
#meta_description ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 55 def if model..present? sanitize_description(model.) else sanitize_description(model.description) end end |
#product_type ⇒ Object
63 64 65 66 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 63 def product_type return '' unless model.filters['product_type'].present? model.filters['product_type'].first end |
#sku_price(sku) ⇒ Object
77 78 79 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 77 def sku_price(sku) pricing.for_sku(sku).sell end |
#variants ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/view_models/workarea/storefront/google_product_feed_view_model.rb', line 68 def variants @variants ||= model.variants.map do |variant| GoogleProductFeedSkuViewModel.wrap( variant, inventory_sku: inventory.for_sku(variant.sku) ) end end |