How can I sort collections by product availability in descending order?

Hello,

I wanted to check the possibility to create a new sorting method to sort products of current collection by the stock availability.

In example, the customer could sort collection page by product availability DESC.

I have search around the Web to find some starting point codes but it looks like nothing has really been done without a paid App or some sort of third party script.

I am checking in the collection.sort_options (https://shopify.dev/api/liquid/objects/collection#collection-sort_options) object to see if I can add something.

Writing this tread as a starting point and to post my researches or code if I came up with something nice!

If you have hints or documentation to read, feel free to share.

Hi @poliquinp ,

Yes. As far as I know, Shopify does not support sort by product quantity by theme code or attributes.

Therefore, the app is the most important thing for it.

@LitCommerce could your give me more information about your app and how you could potentially fix this issue ?