Class: Spree::ProductsController

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

Instance Method Summary collapse

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
30
# 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).
              preload_associations_lazily.
              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