Class: TbCommerce::ProductsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tb_commerce/products_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
# File 'app/controllers/tb_commerce/products_controller.rb', line 6

def index
  @products = @category.products.includes(:product_skus, :images).ordered
  render 'index'
end

#searchObject



20
21
22
23
# File 'app/controllers/tb_commerce/products_controller.rb', line 20

def search
  @products = TbCommerce::Product.search(params[:search]).ordered
  render 'search'
end

#showObject



11
12
13
14
15
16
17
18
# File 'app/controllers/tb_commerce/products_controller.rb', line 11

def show
  if params[:sku] && sku = @product.product_skus.find_by(:sku => params[:sku])
    @cart_item = TbCommerce::CartItem.new(:item => sku)
  else
    @cart_item = TbCommerce::CartItem.new()
  end
  render 'show'
end