Class: Spree::SearchController

Inherits:
StoreController show all
Defined in:
app/controllers/spree/search_controller.rb

Instance Method Summary collapse

Methods inherited from StoreController

#current_taxon, #permitted_products_params, #products_filters_params, #render_404_if_store_not_exists, #store_filter_names, #store_filter_names_hash

Methods included from AnalyticsHelper

#analytics_event_handlers, #track_event, #unsupported_event?, #visitor_id

Methods included from WishlistHelper

#current_wishlist

Methods included from PasswordProtected

#redirect_to_password

Methods included from StorefrontHelper

#as_aspect_ratio, #page_description, #page_image, #paths_equal?, #render_storefront_partials, #show_account_pane?, #svg_country_icon, #tailwind_classes_for

Methods included from ThemeConcern

#default_url_options, #set_theme_view_paths

Instance Method Details

#showObject



7
8
9
# File 'app/controllers/spree/search_controller.rb', line 7

def show
  @current_page = current_theme.pages.find_by(type: 'Spree::Pages::SearchResults')
end

#suggestionsObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/search_controller.rb', line 11

def suggestions
  @products = []
  @taxons = []

  if query.present? && query.length >= Spree::Storefront::Config.search_min_query_length
    products_scope = storefront_products_scope.multi_search(query)
    @products = products_scope.includes(storefront_products_includes)
    @taxons = current_store.taxons.search_by_name(query)
  end
end