Developer forum

Forum » Ecommerce - Standard features » sort by "out of stock"

sort by "out of stock"

Jonas Krarup Dam
Reply

Is there a simple way to sort my product list so that products that have stock <1 are shown at the bottom of the list, when working from an index?

 

The rest of the list should not be sorted by stock status, ofc.

 

The only way I can think of, is to implement an index Extender that has "in stock" as a boolean, but it feels like there should be a simpler way :-) 

 

/Jonas


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply
This post has been marked as an answer

Hi Jonas,

You can try defining a "Gouping" field of type Int32 in the index based on your stock information.

You can set the name to be 1 for values between 1 and 9999999 and 0 for values between -99999 and 0.

Choose Stored and Indexed.

After indexing, you can use this field for sorting just as you do with the regular fields.

Adrian

 

Sort_by_stock.png
Votes for this answer: 1
 
Jonas Krarup Dam
Reply

Clever - thanks Adrian :-) 

 

You must be logged in to post in the forum