Class: Spree::StoreController

Inherits:
BaseController
  • Object
show all
Includes:
AnalyticsHelper, Core::ControllerHelpers::Order, IntegrationsHelper, LocaleUrls, PasswordProtected, Spree::Storefront::PaginationConcern, StorefrontHelper, ThemeConcern, WishlistHelper
Defined in:
app/controllers/spree/store_controller.rb

Instance Method Summary collapse

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?, #spree_storefront_base_cache_key, #spree_storefront_base_cache_scope, #svg_country_icon, #tailwind_classes_for

Methods included from ThemeConcern

#default_url_options, #set_theme_view_paths

Instance Method Details

#current_taxonObject



48
49
50
# File 'app/controllers/spree/store_controller.rb', line 48

def current_taxon
  @current_taxon ||= (current_store.taxons.find_by(id: params[:taxon_id]) if params[:taxon_id].present?)
end

#default_products_sortObject



88
89
90
# File 'app/controllers/spree/store_controller.rb', line 88

def default_products_sort
  'manual'
end

#permitted_products_paramsObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/controllers/spree/store_controller.rb', line 64

def permitted_products_params
  @permitted_products_params ||= params.permit(
    :locale,
    :currency,
    :q,
    :page,
    :per_page,
    :sort_by,
    filter: [
      :min_price,
      :max_price,
      :purchasable,
      :out_of_stock,
      {
        options: [store_filter_names_hash],
        taxon_ids: [],
        taxonomy_ids: [
          taxon_ids: []
        ]
      }
    ]
  )
end

#products_filters_paramsObject



92
93
94
# File 'app/controllers/spree/store_controller.rb', line 92

def products_filters_params
  @products_filters_params ||= permitted_products_params[:filter]&.compact_blank || {}
end

#render_404_if_store_not_existsObject



42
43
44
45
46
# File 'app/controllers/spree/store_controller.rb', line 42

def render_404_if_store_not_exists
  return if current_store.present?

  render 'spree/errors/404', layout: 'application', status: :not_found
end

#store_filter_namesObject



52
53
54
# File 'app/controllers/spree/store_controller.rb', line 52

def store_filter_names
  @store_filter_names ||= Spree::OptionType.filterable.order(:position).pluck(:name)
end

#store_filter_names_hashObject



56
57
58
59
60
61
62
# File 'app/controllers/spree/store_controller.rb', line 56

def store_filter_names_hash
  filter_names = {}
  store_filter_names.each do |filter_name|
    filter_names[filter_name.to_sym] = []
  end
  filter_names
end