Commit 19f20f15 by vulehuan

update code: product on category page

parent caf24a7a
......@@ -2,7 +2,7 @@ class ProductCategoriesController < ApplicationController
add_breadcrumb "Products", :products_path
def show
if ProductCategory.exists?(params[:id])
if ProductCategory.where(id: params[:id]).exists?
term = ProductCategory.find(params[:id])
@items = Product.get_products_by_category(product_category_id: params[:id], page: params[:page], limit: 24)
@title = term.name
......
......@@ -55,11 +55,10 @@ class Product
limit = options[:limit]
product_category_id = options[:product_category_id]
page = options[:page]
return Product.select('id, name, image_medium, price, price_currency')
.where(availability: 'instock', product_category_id: product_category_id)
return Product.where(availability: 'instock', product_category_id: product_category_id)
.where(status: true)
.desc(:created_at).desc(:updated_at).asc(:name)
.paginate(:page => page, :per_page => limit)
.order('created_at DESC').order('updated_at DESC').order('name')
end
#Returns other products
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment