Sha256: c1c1a3d828e1b290ad82be57ad07379b435dfa0303911a5821f9370c5bfc182e

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

class Shop::ProductsController < ApplicationController
  
  skip_before_filter :verify_authenticity_token
  no_login_required
  
  radiant_layout Radiant::Config['shop.product_layout']

  rescue_from ActiveRecord::RecordNotFound do |exception|
    render :template => 'site/not_found', :status => :unprocessable_entity
  end
  
  # GET /shop/search/:query
  # GET /shop/search/:query.js
  # GET /shop/search/:query.json                                  AJAX and HTML
  #----------------------------------------------------------------------------
  def index
    @shop_products = ShopProduct.search(params[:query])
    @radiant_layout = Radiant::Config['shop.category_layout']
    
    respond_to do |format|
      format.html { render }
      format.js   { render :partial => '/shop/products/index/product', :collection => @shop_products }
      format.json { render :json    => @shop_products.to_json(ShopProduct.params) }
    end
  end
  
  # GET /shop/:category_handle/:handle
  # GET /shop/:category_handle/:handle.js
  # GET /shop/:category_handle/:handle.json                       AJAX and HTML
  #----------------------------------------------------------------------------
  def show
    if @shop_product = ShopProduct.find(:first, :conditions => { :sku => params[:sku] })
      @shop_category = @shop_product.category unless @shop_product.nil?
    
      @radiant_layout = @shop_product.layout.name rescue (raise "Couldn't find Layout with id #{@shop_product.layout_id}")
      @title = @shop_product.name
    
      respond_to do |format|
        format.html { render }
        format.js   { render :partial => '/shop/products/index/product', :locals => { :product => @shop_product } }
        format.json { render :json => @shop_product.to_json(ShopProduct.params) }
      end
    else
      raise ActiveRecord::RecordNotFound
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-shop-extension-0.10.0 app/controllers/shop/products_controller.rb