Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to sort products in ModX by quantity?
There is such an output of goods through miniShop2 modx:
[[!pdoPage?
&element=`msProducts`
&parents=`1341,1342,1343,1344`
&limit=`4`
&sortby = `Data.id`
&where=`{"Data.stock:>":0}`
&tpl = `ms.NPSlider`
]]
Sorting by Data.stock does not work. And it is required to display only products with a quantity greater than 0.
Answer the question
In order to leave comments, you need to log in
Here is from a live project:
[[!pdoPage?
&element=`msProducts`
&parents=`0`
&loadModels=`gallery,easycomm`
&leftJoin=`{
"270x270": {"class":"msProductFile","alias":"270x270", "on": "270x270.product_id = msProduct.id AND 270x270.path LIKE '%/270x270/' AND 270x270.rank=0"}
,"270x270x1": {"class":"msProductFile","alias":"270x270x1", "on": "270x270x1.product_id = msProduct.id AND 270x270x1.path LIKE '%/270x270/' AND 270x270x1.rank=1"}
,"ecThread": {"class": "ecThread","on": "msProduct.id = ecThread.resource"}
}`
&select=`{
"msProduct":"*"
,"270x270":"270x270.url as 270x270"
,"270x270x1":"270x270x1.url as 270x270x1"
,"ecThread": "ecThread.rating_simple as rating"
}`
&limit=`24`
&where=`{"Data.old_price:>":0}`
&sortby=`id` &sortdir=`desc`
&ajaxMode=`default`
]]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question