Sha256: 6432b78c00085b50779ee1c869c9002cbd9668d0fb59ebce41670931a2671530

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 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
      @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

2 entries across 2 versions & 1 rubygems

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