Class: Workarea::Search::CategoryBrowse

Inherits:
Object
  • Object
show all
Includes:
CategorizationFiltering, Facets, LoadProductResults, Pagination, ProductDisplayRules, Query
Defined in:
app/queries/workarea/search/category_browse.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pagination

#each_by, #from, #page, #per_page, #results, #size

Methods included from ProductDisplayRules

#active_for_segments_clause, #displayable_when_out_of_stock_sort_clause, #inventory_display_clause, #preview_current_release_clause, #product_display_query_clauses

Methods included from CategorizationFiltering

#category_filters, #category_ids, #category_query_clauses

Methods included from LoadProductResults

#load_inventory_from, #load_model_from, #load_pricing_from

Methods included from Facets

#facets, #range_facets, #terms_facets

Methods included from Query

#additional_options, #body, #id, #initialize, #load_model_from, #loaded_results, #query_string, #response, #results, #scroll, #stats, #total

Class Method Details

.available_sortsObject



13
14
15
16
17
18
19
20
21
# File 'app/queries/workarea/search/category_browse.rb', line 13

def self.available_sorts
  Sort::Collection.new(
    Sort.top_sellers,
    Sort.popularity,
    Sort.newest,
    Sort.price_asc,
    Sort.price_desc
  )
end

Instance Method Details

#aggregationsObject



31
32
33
# File 'app/queries/workarea/search/category_browse.rb', line 31

def aggregations
  facets.map(&:aggregation).reduce(&:merge)
end

#category_idObject



54
55
56
57
58
# File 'app/queries/workarea/search/category_browse.rb', line 54

def category_id
  if params[:category_ids].respond_to?(:first)
    params[:category_ids].first
  end
end

#post_filterObject



35
36
37
38
39
40
41
# File 'app/queries/workarea/search/category_browse.rb', line 35

def post_filter
  {
    bool: {
      must: facets.map(&:post_filter_clause).reject(&:blank?)
    }
  }
end

#queryObject



23
24
25
26
27
28
29
# File 'app/queries/workarea/search/category_browse.rb', line 23

def query
  {
    bool: {
      must: product_display_query_clauses + category_query_clauses
    }
  }
end

#sortObject



43
44
45
46
47
48
# File 'app/queries/workarea/search/category_browse.rb', line 43

def sort
  result = current_sort_clauses
  add_displayable_out_of_stock_sort_clause(result)
  result << views_score_sort_clause
  result
end

#sortsObject



50
51
52
# File 'app/queries/workarea/search/category_browse.rb', line 50

def sorts
  Array(params[:sort])
end