skip to Main Content

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 ?

2

Answers


  1. Chosen as BEST ANSWER

    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(MagentoFrameworkDBSelect::ORDER)
            ->order(new Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
    }
    

  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search