Class: Spree::PageSections::RelatedProducts

Inherits:
Spree::PageSection show all
Defined in:
app/models/spree/page_sections/related_products.rb

Constant Summary

Constants inherited from Spree::PageSection

Spree::PageSection::BACKGROUND_COLOR_DEFAULT, Spree::PageSection::BORDER_COLOR_DEFAULT, Spree::PageSection::BOTTOM_BORDER_WIDTH_DEFAULT, Spree::PageSection::BOTTOM_PADDING_DEFAULT, Spree::PageSection::TEXT_COLOR_DEFAULT, Spree::PageSection::TOP_BORDER_WIDTH_DEFAULT, Spree::PageSection::TOP_PADDING_DEFAULT

Instance Attribute Summary

Attributes inherited from Spree::PageSection

#default_blocks

Instance Method Summary collapse

Methods inherited from Spree::PageSection

#available_blocks_to_add, #blocks_available?, #can_be_deleted?, #can_be_sorted?, #can_sort_blocks?, #copy_rich_text_fields_from, #deep_clone, #deep_clone_links, #display_name, #dup, #restore_design_settings_to_defaults, #rich_text_fields, #role, role, #theme, #to_partial_path

Instance Method Details

#icon_nameObject



13
14
15
# File 'app/models/spree/page_sections/related_products.rb', line 13

def icon_name
  'tags'
end

#layoutObject



21
22
23
# File 'app/models/spree/page_sections/related_products.rb', line 21

def layout
  'swiper'
end

#lazy?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/spree/page_sections/related_products.rb', line 17

def lazy?
  true
end

#lazy_path(variables) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/spree/page_sections/related_products.rb', line 25

def lazy_path(variables)
  section_id = variables[:section].id
  url_options = variables[:url_options] || {}

  if variables[:product].present?
    product_id = variables[:product].id
    Spree::Core::Engine.routes.url_helpers.related_product_path(
      product_id,
      section_id: section_id,
      **url_options
    )
  elsif variables[:post].present?
    post_id = variables[:post].id
    Spree::Core::Engine.routes.url_helpers.related_products_post_path(
      post_id,
      section_id: section_id,
      **url_options
    )
  end
end