Sha256: 61a5e5e23881bce5a589ac62b9d1e39bb5e029a7192685e5577451845aa89a23

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

class ProductsController < Spree::BaseController
  helper :taxons
  resource_controller
  actions :show, :index

  index do
    before do
      @product_cols = 3
    end
  end

  def change_image
    @product = Product.available.find_by_param(params[:id])
    img = Image.find(params[:image_id])
    render :partial => 'image', :locals => {:image => img}
  end

  private

    def collection
      if params[:taxon]
        @taxon = Taxon.find(params[:taxon])

        @collection ||= Product.available.find(
          :all, 
          :conditions => ["products.id in (select product_id from products_taxons where taxon_id in (" +  @taxon.descendents.inject( @taxon.id.to_s) { |clause, t| clause += ', ' + t.id.to_s} + "))" ], 
          :page => {:start => 1, :size => 10, :current => params[:p]}, 
          :include => :images)
      else
        @collection ||= Product.available.find(:all, :page => {:start => 1, :size => 10, :current => params[:p]}, :include => :images)
      end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree-0.4.0 app/controllers/products_controller.rb
spree-0.4.1 app/controllers/products_controller.rb
spree-0.5.0 app/controllers/products_controller.rb
spree-0.5.1 app/controllers/products_controller.rb