Class: Spree::Taxons::TouchFeaturedSections

Inherits:
Object
  • Object
show all
Includes:
ServiceModule::Base
Defined in:
app/services/spree/taxons/touch_featured_sections.rb

Instance Method Summary collapse

Methods included from ServiceModule::Base

prepended

Instance Method Details

#call(taxon_ids:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/spree/taxons/touch_featured_sections.rb', line 6

def call(taxon_ids:)
  return if taxon_ids.empty?

  featured_taxons = Spree::PageSections::FeaturedTaxon.published.by_taxon_id(taxon_ids)

  return if featured_taxons.empty?

  featured_taxons.touch_all
  pages = Spree::Page.where(id: featured_taxons.where(pageable_type: 'Spree::Page').pluck(:pageable_id))
  pages.touch_all
  themes = Spree::Theme.where(id: pages.where(pageable_type: 'Spree::Theme').pluck(:pageable_id).uniq)
  themes.touch_all
end