Prior to my store allowing back orders, when browsing all products that were "In Stock" were displayed with a higher priority over products that were "Out of stock".
Since allowing back orders on my website, now the logic for this functionality is flawed. Now products with 0 stock are mixed with products with stock making it difficult for visitors to find products that are available for immediate purchase.
What I would like to do is show products with the most quantity first and not just "In Stock"
I'm finding plenty of information about sorting products by "in stock" but nothing about product quantities.
What is the best method to achieve sorting products by the largest quantities first when browsing?
Best Answer
Here is what I got.
The following code works for simple products with manageable stock only. It all falls over if configurable, grouped or products for which you don't manage the stock are involved.
You will need a new extension, just like Richard also suggested that rewrites the product collection resource model.
Here is the full extension. Let's name it
Easylife_Sorting
.You will need the following files:
app/etc/modules/Easylife_Sorting.xml
- the declaration fileapp/code/local/Easylife/Sorting/etc/config.xml
- the configuration file:app/code/local/Easylife/Sorting/Model/Resource/Product/Collection.php
- the rewritten collection model