Jump to content

[MODULE] Sort products in-stock first

Recommended Posts

This module allows sorting products in-stock first when listing different product pages and blocks. Also the module has a special price sorting feature that allows to sort products with combinations properly when a base price of a product is zero.
With this module a customer sees always novel products in the first place and thereby save his time and nerves to find needed product that is in-stock.
Support Prestashop versions: 1.5.x - 1.6.x
Installation: normal
Core modifications: no
Including documentation: yes
The module will work correctly with different modules that are using Prestashop’s core to get products list for different purposes (like random products functionality, bestsellers products functionality and so on). But by default the module doesn’t work together with «Layered navigation block» module and others modules that are using hooks for overriding behavior of Prestashop’s core (i.e. not using core classes or overridden classes instead). The «Sort products in-stock first» module is not easy to make it work with complex filtering modules like «Layered navigation block», «Advanced Search 4» and so on. They should be modified for this case. There is a manual for this module that has instructions to make work with «Layered navigation block» module.
How to buy
Here at Addons
On the my site




  • Like 1

Share this post

Link to post
Share on other sites

Hello Zapalm,


Very nice module, seems to be very useful.

Congrats with this new module.


Best regards,



  • Haha 1

Share this post

Link to post
Share on other sites


I have bought your module and I would like to make it work with Advanced Search 4. Is it possible ?

I have seen the instructions in the documentation about Layered navigation block module, but not about Advanced Search 4. 

Thank you & Regards

Axel Verger

Share this post

Link to post
Share on other sites



This is a brief instruction to make work InStockFirst module with other modules.


1 Find a file with the function in your module that generates products content like getProducts() or getProductsSearched() or getProductByFilters() or something else.


2 Find the main SQL-code in this function that querying products array (it should be the largest).


3 Then you need to remove a part of this SQL-code with 'LIMIT' instruction (pay attention to variables like $p and $n that are near of this instruction).


4 Then find where is placed the call of 'Tools::orderbyPrice($result, $orderWay);' function.


5 After this line you need to insert the line:

Instockfirst::moveOutOfStock($result, $p - 1, $n);


6 Make sure $result, $p and $n variables are have the same names that are used before in other queries or functions calls. Make also sure that the module InStockFirst is installed and enabled.


7 Save the file and check. That’s all.

Share this post

Link to post
Share on other sites

Always great support from the creator, module is working perfectly.

  • Thanks 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More