Module: Workarea::Search::Storefront::Product::Facets

Extended by:
ActiveSupport::Concern
Included in:
Workarea::Search::Storefront::Product
Defined in:
app/models/workarea/search/storefront/product/facets.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#facetsHash

Fields for faceting, as defined by the contents of the filters hash on the Catalog::Product.

Returns:

  • (Hash)


38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/workarea/search/storefront/product/facets.rb', line 38

def facets
  result = model.filters.reduce({}) do |memo, tuple|
    key, value = *tuple
    memo[key.to_s.systemize] = FacetValues.sanitize(value)
    memo
  end

  result[:category] = primary_navigation if primary_navigation.present?
  result[:category_id] = category_id
  result
end