Commit caf24a7a by vulehuan

update code: product on homepage

parent a7c40115
......@@ -35,23 +35,19 @@ class Product
# Returns recommended products (order by rate, and available)
def self.get_recommended_products(options = { limit: 8 })
limit = options[:limit]
# return Product.select('id, name, image_medium, price, price_currency')
# .where(availability: 'instock')
# .where(status: true)
# .order('review_rate DESC').order('review_count DESC')
# .limit(limit)
return Array.new
return Product.where(availability: 'instock')
.where(status: true)
.desc(:review_rate).desc(:review_count)
.limit(limit)
end
# Returns newest products
def self.get_newest_products(options = { limit: 8 })
limit = options[:limit]
# return Product.select('id, name, image_medium, price, price_currency')
# .where(availability: 'instock')
# .where(status: true)
# .order('created_at DESC').order('updated_at DESC').order('name')
# .limit(limit)
return Array.new
return Product.where(availability: 'instock')
.where(status: true)
.desc(:created_at).desc(:updated_at).asc(:name)
.limit(limit)
end
# Returns products in a category
......
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