[[+content_image]]
A
A
ak_wi2018-09-03 22:06:21
MODX
ak_wi, 2018-09-03 22:06:21

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

[[+comments_count]] answer(s)
A
Alex-1917, 2018-09-03
@ak_wi

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`
          ]]

I
Igor, 2018-09-13
@ig0r74

&includeTVs=`stock`
&sortby=`stock`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question