Sort products by stock and name

I would like to list products which are in stock before the ones which are currently sold out. Is there a way to get the stock value in the retrieval call? Currently I get my products with pdoPage and TaggerGetResourcesWhere:


The stock value is within the products TV if I’m not mistaken, but how am I able to sort by that?

Any ideas on this?

What type of TV do you use, product list or matrix?

With the product list tv, that holds a comma separated list of products, which you can’t immediately sort in on a query for resources.

With the matrix tv, that holds the matrix ID which in theory could be used to join the matrix instance > product instance to query the stock field or the price index table to sort on current price.

With a resource product implementation you should have a simple stock tv to look at.

Yes, I’m using the Products List TV. Too bad, but was expecting that already. Thanks for clarifying, though!