Posted on

Stock and Out Of Stock filter in Layered Navigation

I try to add Stock and Out Of Stock filter in the Layered Navigation.
I set the configuration of the attribute “quantity_and_stock_status”:

In the storefront I look the filter, but if the configuration -> Display Product out of Stock is enabled it counts all items without stock status condition.

I have seen the following in the code. Magento does not filter if the option Display Product out of Stock is enabled.

if (!$this->inventoryConfig->isShowOutOfStock($currentScopeId)) {
$select->where(‘stock_index.stock_status = ?’, Stock::STOCK_IN_STOCK);
}

I have tried to replace this class but the methods are private and it gives error.

Is there any alternative?

Leave a Reply

Your email address will not be published. Required fields are marked *