Class: Spree::ProductsController

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

Instance Attribute Summary

Attributes included from Core::ControllerHelpers

#title

Instance Method Summary collapse

Methods included from Core::ControllerHelpers

#associate_user, included, #try_spree_current_user

Instance Method Details

#indexObject



9
10
11
12
13
# File 'app/controllers/spree/products_controller.rb', line 9

def index
  @searcher = Config.searcher_class.new(params)
  @products = @searcher.retrieve_products
  respond_with(@products)
end

#showObject



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

def show
  return unless @product

  @variants = Variant.active.includes([:option_values, :images]).where(:product_id => @product.id)
  @product_properties = ProductProperty.includes(:property).where(:product_id => @product.id)

  referer = request.env['HTTP_REFERER']
  if referer
    referer_path = URI.parse(request.env['HTTP_REFERER']).path
    if referer_path && referer_path.match(/\/t\/(.*)/)
      @taxon = Taxon.find_by_permalink($1)
    end
  end

  respond_with(@product)
end