Class: Workarea::Search::StorefrontSearch::ProductAutoRedirect

Inherits:
Object
  • Object
show all
Includes:
Middleware
Defined in:
app/queries/workarea/search/storefront_search/product_auto_redirect.rb

Instance Method Summary collapse

Methods included from Middleware

#initialize

Instance Method Details

#call(response) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'app/queries/workarea/search/storefront_search/product_auto_redirect.rb', line 7

def call(response)
  if !response.has_filters? && response.total == 1
    response.redirect = product_path(
      response.query.results.first[:model]
    )
  else
    yield
  end
end