Sha256: 3a27050a0fada1e288af9685c7e9a88affa8a9f6fc41c3656fbe2b11107b9bf7

Contents?: true

Size: 993 Bytes

Versions: 5

Compression:

Stored size: 993 Bytes

Contents

module Spree
  class ProductsController < BaseController
    HTTP_REFERER_REGEXP = /^https?:\/\/[^\/]+\/t\/([a-z0-9\-\/]+)$/
    rescue_from ActiveRecord::RecordNotFound, :with => :render_404
    helper 'spree/taxons'

    respond_to :html

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

    def show
      @product = Product.active.find_by_permalink!(params[:id])
      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.match(HTTP_REFERER_REGEXP)
        @taxon = Taxon.find_by_permalink($1)
      end

      respond_with(@product)
    end

    private
      def accurate_title
        @product ? @product.name : super
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_core-1.0.7 app/controllers/spree/products_controller.rb
spree_core-1.0.6 app/controllers/spree/products_controller.rb
spree_core-1.1.0 app/controllers/spree/products_controller.rb
spree_core-1.0.4 app/controllers/spree/products_controller.rb
spree_core-1.1.0.rc2 app/controllers/spree/products_controller.rb