Class: Feed::ItemPresenter

Inherits:
BasePresenter show all
Defined in:
app/services/feed/item_presenter.rb

Overview

Service object: item presenter.

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#all_imagesObject



10
11
12
# File 'app/services/feed/item_presenter.rb', line 10

def all_images
  r.image_profiles.website_image_profiles_excluding_card.image_order.includes(:image).map(&:image)
end

#catalog_itemsObject



22
23
24
# File 'app/services/feed/item_presenter.rb', line 22

def catalog_items
  r.catalog_items.available_for_edi_feeds
end

#google_product_category_idObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/feed/item_presenter.rb', line 26

def google_product_category_id
  slt = primary_product_line&.slug_ltree.to_s
  pc_url = product_category&.url
  return 1897   if /thermostats/.match?(pc_url) # Hardware  | Heating, Ventilation & Air Conditioning  | HVAC Controls  | Thermostats
  return 1519   if pc_url =~ /controls/ || slt.start_with?('floor_heating.control.integration') # Hardware  | Heating, Ventilation & Air Conditioning  | HVAC Controls
  return 2729   if slt.start_with?('countertop_heater') && pc_url =~ /heating-elements/ # Hardware	Building Materials	Countertops
  return 499_873 if slt.start_with?('floor_heating') # | Hardware  | Heating, Ventilation & Air Conditioning
  return 595    if slt.start_with?('led_mirror', 'mirror_defogger') # Home & Garden	Decor	Mirrors
  return 2060   if slt.start_with?('infrared_heating_panels') # | Home & Garden  | Household Appliances  | Climate Control Appliances  | Heating Radiators
  return 4544   if slt.start_with?('roof_and_gutter_deicing') # Hardware	Building Materials	Roofing	Gutter Accessories
  return 5362   if slt.start_with?('snow_melting') #	Home & Garden	Lawn & Garden	Snow Removal
  return 586    if slt.start_with?('towel_warmer') # | Home & Garden  | Bathroom Accessories  | Towel Racks & Holders
  return 122 if /insulation/.match?(pc_url) #  Hardware	Building Materials	Insulation

  115 #	Hardware > Building Materials
end

#product_typeObject



43
44
45
# File 'app/services/feed/item_presenter.rb', line 43

def product_type
  Feed::ProductTypeGenerator.process(item: r)
end

#public_specificationsObject



18
19
20
# File 'app/services/feed/item_presenter.rb', line 18

def public_specifications
  r.rendered_product_specifications.reject { |_k, v| v[:visibility] == 'private' }
end

#seo_keywordsObject



6
7
8
# File 'app/services/feed/item_presenter.rb', line 6

def seo_keywords
  r.seo_keywords.presence || product_line_page_keywords(r.primary_product_line)
end

#videosObject



14
15
16
# File 'app/services/feed/item_presenter.rb', line 14

def videos
  Item::VideoRetriever.new(tags: 'for-product-page').process(item).all_videos
end