Magento 2.4.5 category page out of stock products not showing.
Even magento admin -> stores -> config -> catalog -> inventory setting is enabled ?
I tried with default magento but not found any solution. Can anyone facing same issue and have solution ?
I debug a lot and finally found the major bug in 2.4.5.
vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php
Just change apply function like 2.4.4
public function apply()
{
if (empty($this->searchResult->getItems())) {
$this->collection->getSelect()->where('NULL');
return;
}
//$ids = $this->getProductIdsBySaleability();
//if (count($ids) == 0) {
$items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage);
foreach ($items as $item) {
$ids[] = (int)$item->getId();
}
//}
$orderList = implode(',', $ids);
$this->collection->getSelect()
->where('e.entity_id IN (?)', $ids)
->reset(\Magento\Framework\DB\Select::ORDER)
->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
}