magento/inventory

Not indexing In-stock products

adarshkhatri opened this issue · 3 comments

MSI plugin class prevents indexing in-stock products in special scenarios. When indexing Magento indexes products in a batch of 500 (default). On each batch, it goes to loop until it finds 0 products. Let's say there are 50,000 SKUs and the system is indexing
when on the 10th batch, it finds 460 products, and the MSI plugin checks if these consist of any out-of-stock products and returns only in-stock arrays. If none is found it then returns an empty array. Now, when Magento receives 0 products it thinks it reached the end of products and then stops indexing after that batch. Meaning there could be more products that are in stock that needs to be indexed.

In Magento this line https://github.com/magento/magento2/blob/28c1f28a2552de69158b40d1eaf84e45430c16f9/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php#L382 it loops through catalog_entity_table in a batch of 500 (default).

When MSI returns 0 products of that batch (

), Magento thinks there are no more products to index and stops indexing rest of the products.

Preconditions (*)

  1. Magento Version: 2.4.3-p1

Steps to reproduce (*)

  1. Have SKUs more than 20,000 or
  2. Configure the indexing batch to less than 100 when having less SKUs https://developer.adobe.com/commerce/php/development/components/indexing/optimization/

Expected result (*)

  1. Should index all in-stock products when Display Out of Stock Products is set to No in config

Actual result (*)

  1. Doesn't index all in-stock products

Hi @adarshkhatri. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


That's not how it works and if it was don't you think you would see this on a default instance with sample data.

You can try with the default instance, at least for me (I am in the commerce version) it is behaving this way. Regardless, the system should index all the in-stock products, even out of 100,000 products, only 2 items (entity ID 1 and entity ID 100,000 are in stock). Currently, the system only indexes entity ID 1.