Sha256: da411fd6ffd61ff9f3b50440f8d8ed635e622131391c619f2a0726c20ccfdf5d

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

module Spree
  ProductsController.class_eval do
    HTTP_REFERER_REGEXP = /^https?:\/\/[^\/]+\/t\/([a-z0-9\-\/]+)$/ unless defined? HTTP_REFERER_REGEXP

    def show
      @product = Spree::Product.active.find_by_permalink!(params[:id])
      return unless @product

      if Spree::ActiveSale::Event.is_live? @product
        @variants = Spree::Variant.active.includes([:option_values, :images]).where(:product_id => @product.id)
        @product_properties = Spree::ProductProperty.includes(:property).where(:product_id => @product.id)

        referer = request.env['HTTP_REFERER']

        if referer && referer.match(HTTP_REFERER_REGEXP)
          @taxon = Spree::Taxon.find_by_permalink($1)
        end

        respond_with(@product)
      else
        redirect_to root_url, :error => t('spree.active_sale.event.flash.error')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_active_sale-1.0.6 app/controllers/products_controller_decorator.rb