I'm trying to implement a sort order in my product listings so that all of the out of stock products are last.
I'm unsure how or if this is possible because the stock is set on the variants of a product and I'm listing the products.
The stock level would need to take into account the stock of all the products variants.
I know we have the ability to only fetch products that have stock with the criteria hasVariant: { hasStock: true }
, but is there a way I can sort them using the .order()
criteria?