Class: Spree::ProductsController

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

Instance Method Summary collapse

Methods inherited from StoreController

#current_taxon, #default_products_sort, #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

#indexObject



8
9
10
# File 'app/controllers/spree/products_controller.rb', line 8

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


19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/spree/products_controller.rb', line 19

def related
  @current_page = current_theme.pages.product_details.first
  section_scope = @current_page.sections.related_products
  @section = section_scope.find_by(id: params[:section_id]) || section_scope.first
  load_product
  # An interesting thing is that since we're querying the translations table (in the multi_search),
  # when using not default locale, our related products are different for different locales.
  @products = storefront_products_scope.where.not(id: @product.id).
              multi_search(@product.name).includes(storefront_products_includes).
              limit(@section.preferred_max_products_to_show)
end

#showObject



12
13
14
15
16
17
# File 'app/controllers/spree/products_controller.rb', line 12

def show
  load_product
  redirect_if_legacy_path

  @current_page = current_theme.pages.product_details.first
end