cancel
Showing results for 
Search instead for 
Did you mean: 

Out of stock products at the end of the category page - Magento 2.2.x

Out of stock products at the end of the category page - Magento 2.2.x

I am running Magento 2.2.4 version and I need to display Out of stock products at the end of the categories page.

 

I have added the below code in vendor/magento/module-catalog/Block/Product/layer.php 

 

$collection->joinField('in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id', 'in_stock>=0', 'left')->setOrder('in_stock','desc');

 

But its not working

 

Can anyone let me know how to display out of stock products at the end of the page?

 

Thanks.  

3 REPLIES 3

Re: Out of stock products at the end of the category page - Magento 2.2.x

You can refer below links for out of stock product at end of list page.

Magento-2 Display out-of-stock products at the end of the-list-page

Using above blog entire module is given for display out of stock product at end of page for category listing page and Search result page.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Out of stock products at the end of the category page - Magento 2.2.x

The url you mentioned that code don't work

Re: Out of stock products at the end of the category page - Magento 2.2.x

the solution offered in your blog breaks up sorting by name or by price.