Class: Workarea::Admin::SearchCustomizationProductRulesViewModel

Inherits:
ProductRulesPreviewViewModel show all
Defined in:
app/view_models/workarea/admin/search_customization_product_rules_view_model.rb

Instance Method Summary collapse

Methods inherited from ProductRulesPreviewViewModel

#base_query, #results, #show_all?, wrap

Instance Method Details

#display_results?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/view_models/workarea/admin/search_customization_product_rules_view_model.rb', line 20

def display_results?
  true # With query we can always show preview even without rules
end

#searchWorkarea::Search::ProductSearch

Fetches search results of products for product search. Extends search class with Search::AdminProductRulesPreview to allow overriding display rules.

Returns:

  • (Workarea::Search::ProductSearch)

    enumerable collection of the search results



11
12
13
14
15
16
17
18
# File 'app/view_models/workarea/admin/search_customization_product_rules_view_model.rb', line 11

def search
  @search ||= Search::ProductSearch.new(
    q: model.query,
    rules: model.product_rules.usable,
    page: options[:page] || 1,
    show_all: show_all?
  ).tap { |s| s.extend(Search::AdminProductRulesPreview) }
end