Module: Spree::TaxonsHelper

Defined in:
app/helpers/spree/taxons_helper.rb

Instance Method Summary collapse

Instance Method Details

#taxon_products(taxon) ⇒ ActiveRecord::Relation<Spree::Product>

Returns products for the taxon.

Parameters:

  • taxon (Spree::Taxon)

Returns:

  • (ActiveRecord::Relation<Spree::Product>)

    products for the taxon



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/spree/taxons_helper.rb', line 5

def taxon_products(taxon)
  @products_cache ||= {}
  @products_cache[taxon.id] ||= begin
    finder_params = {
      store: current_store,
      filter: { taxons: taxon.id },
      currency: current_currency,
      sort_by: 'default'
    }

    storefront_products_finder.new(scope: current_store.products.includes(storefront_products_includes), params: finder_params).execute
  end
end