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
19f20f15
Commit
19f20f15
authored
Nov 06, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code: product on category page
parent
caf24a7a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
4 deletions
+3
-4
venshop_app/app/controllers/product_categories_controller.rb
+1
-1
venshop_app/app/models/product.rb
+2
-3
No files found.
venshop_app/app/controllers/product_categories_controller.rb
View file @
19f20f15
...
...
@@ -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
...
...
venshop_app/app/models/product.rb
View file @
19f20f15
...
...
@@ -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
...
...
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