Home > Enterprise >  Magento 2.4.5 category page out of stock products not showing
Magento 2.4.5 category page out of stock products not showing

Time:10-10

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 ?

CodePudding user response:

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)"));
}

CodePudding user response:

There must be issued in your product or Magento Elasticsearch configuration. You need to perform steps to reproduce in displaying the Out of Stock Products.

To display out-of-stock products from admin: Follow the steps:

1: Stores>Configuration>Catalog>Inventory 2: Open the Stock Options dropdown. 3: Set Yes in the Display Out of Stock Products option

If that doesn't work, check your Elasticsearch version. Also cleared cache: System->Cache Management

If Memcached or Redis cache is configured clear the cache first. Finally, also, check your theme to display out of stock it can also create an issue with it.

That's it

  • Related