Class: Spree::StoreController

Inherits:
BaseController
  • Object
show all
Includes:
AnalyticsHelper, Core::ControllerHelpers::Order, IntegrationsHelper, LocaleUrls, PasswordProtected, 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?, #svg_country_icon, #tailwind_classes_for

Methods included from ThemeConcern

#default_url_options, #set_theme_view_paths

Instance Method Details

#current_taxonObject



45
46
47
# File 'app/controllers/spree/store_controller.rb', line 45

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

#default_products_sortObject



85
86
87
# File 'app/controllers/spree/store_controller.rb', line 85

def default_products_sort
  'manual'
end

#permitted_products_paramsObject



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

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



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

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

#render_404_if_store_not_existsObject



39
40
41
42
43
# File 'app/controllers/spree/store_controller.rb', line 39

def render_404_if_store_not_exists
  return if current_store.present?

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

#store_filter_namesObject



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

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

#store_filter_names_hashObject



53
54
55
56
57
58
59
# File 'app/controllers/spree/store_controller.rb', line 53

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