Magento 2.3 Inventory Index Error – Product Doesn’t Exist

indexinginventorymagento2.3msi

The inventory index doesn't get re-indexed, it gives this message:

The product that was requested doesn't exist. Verify the product and try again.

In other questions I found that there could be products without SKU, but there aren't any in my database.

I have read here that the re-indexation process generates a table with virtual stock based (among others) on quantity from assigned stocks.
Now I found that there are SKU's in my inventory source (default source) for items I deleted, so products with these SKU's do not exist. Could this cause this issue?

If this causes the issue, what should I delete/update? I do not know in what table this inventory is stored. Or if there are any other sources/tables that need these items deleted.

Best Answer

Recently we experienced this very issue too. Solution in our case was making sure the inventory_source_item MySQL table does not contain any defunct SKU's. To lookup corrupted records in said table, try next MySQL query:

SELECT isi.* FROM inventory_source_item isi LEFT JOIN catalog_product_entity cpe ON isi.sku = cpe.sku WHERE cpe.sku IS NULL;

Removing the resulting rows had the inventory indexer working again.

Seems like a foreign key on the SKU (within the inventory_source_item table, pointing to catalog_product_entity) is lacking. Not sure if such key is missing on purpose, but adding one with ON DELETE CASCADE should prevent the error message from occurring again. Although it is advised to have this confirmed by Magento over a GitHub issue / report. Could not find any related tickets at the moment, so this is still to be reported.

Related Topic