Class: Workarea::Api::Storefront::SearchSuggestionViewModel

Inherits:
Storefront::SearchSuggestionViewModel
  • Object
show all
Defined in:
app/view_models/workarea/api/storefront/search_suggestion_view_model.rb

Instance Method Summary collapse

Instance Method Details

#urlObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/view_models/workarea/api/storefront/search_suggestion_view_model.rb', line 5

def url
  helpers = Api::Storefront::Engine.routes.url_helpers

  if suggestion_type == 'product'
    helpers.product_path(product)
  elsif suggestion_type == 'search'
    helpers.search_path(q: name)
  elsif suggestion_type == 'category'
    helpers.category_path(source['slug'])
  elsif suggestion_type == 'page'
    helpers.page_path(source['slug'])
  end
end