Skip to content

Instantly share code, notes, and snippets.

@cloudbring
Created May 6, 2011 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudbring/959389 to your computer and use it in GitHub Desktop.
Save cloudbring/959389 to your computer and use it in GitHub Desktop.
class ProductsController < Spree::BaseController
HTTP_REFERER_REGEXP = /^https?:\/\/[^\/]+\/t\/([a-z0-9\-\/]+)$/
#prepend_before_filter :reject_unknown_object, :only => [:show]
before_filter :load_data, :only => :show
resource_controller
helper :taxons
actions :show, :index
# def index
# render :layout => params[:template]
# end
private
def load_data
load_object
@variants = Variant.active.find_all_by_product_id(@product.id,
:include => [:option_values, :images])
@product_properties = ProductProperty.find_all_by_product_id(@product.id,
:include => [:property])
@selected_variant = @variants.detect { |v| v.available? }
referer = request.env['HTTP_REFERER']
if referer && referer.match(HTTP_REFERER_REGEXP)
@taxon = Taxon.find_by_permalink($1)
end
end
def collection
@searcher = Spree::Config.searcher_class.new(params)
@products = @searcher.retrieve_products
end
def accurate_title
@product ? @product.name : nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment