Class: Workarea::Storefront::SearchViewModel
Instance Method Summary
collapse
#customization, #customization_content_blocks_for
#content_lookup, #no_results_content, #results_content
#browser_title, #content, #content_blocks, #content_blocks_for, #meta_description, #open_graph_asset
#facets, #filters, #has_filters?, #product_browse_cache_key
Methods included from Pagination
#first_page?, #last_page?, #next_page, #prev_page, #second_page?, #total_pages
Instance Method Details
#product_breadcrumb_params ⇒ Object
27
28
29
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 27
def product_breadcrumb_params
{ via: Navigation::SearchResults.new(search_query.params).to_gid_param }
end
|
#products ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 13
def products
@products ||=
begin
view_models = query.results.map do |result|
ProductViewModel.wrap(
result[:model],
result.merge(options).merge(product_breadcrumb_params).merge(params)
)
end
PagedArray.from(view_models, page, per_page, total)
end
end
|
#query_suggestions ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 31
def query_suggestions
@query_suggestions ||=
begin
all = Recommendation::Searches.find(options[:q]) +
model.query_suggestions
all.uniq.take(3)
end
end
|
#search_query ⇒ Object
9
10
11
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 9
def search_query
query
end
|
#sort ⇒ Object
41
42
43
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 41
def sort
query.class.available_sorts.find(options[:sort])
end
|
#sorts ⇒ Object
45
46
47
|
# File 'app/view_models/workarea/storefront/search_view_model.rb', line 45
def sorts
query.class.available_sorts.map { |s| [s.name, s.slug] }
end
|