0

The items (products) come up in alpha order currently. Is there a way to push all of the “Not in Stock” items to the end of the list when displaying entries?

1 Answer 1

1

I don't think there will be a way to do it without a custom query. Something along the lines of:

SELECT entry_id 
FROM exp_store_stock
WHERE track_stock = '1'
ORDER BY stock_level DESC

One quick and easy way to use a custom query in place of a channel:entries tag is to use the Channel Query module. This template code works and should be a good starting point:

{exp:channel_query 
    sql="SELECT entry_id 
      FROM exp_store_stock
      WHERE track_stock = '1'
      ORDER BY stock_level DESC"
    parse="inward"
}
    {exp:store:product entry_id="{entry_id}"}
        {title}: {total_stock}
    {/exp:store:product}
{/exp:channel_query}

(Tested with Store 2.3.1 and EE 2.9.0)

1
  • This is what I though from the beginning that it will require custom query. Channel Query module should help a lot. Thanks! Feb 24, 2015 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.