Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanvl
venshop
Commits
caf24a7a
Commit
caf24a7a
authored
Nov 06, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code: product on homepage
parent
a7c40115
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
venshop_app/app/models/product.rb
+8
-12
No files found.
venshop_app/app/models/product.rb
View file @
caf24a7a
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment