Skip to content

Creating source items through the REST API does not update cataloginventory_stock_status

I’m trying to troubleshoot a module whose mview has a subscription on the table cataloginventory_stock_status to reindex products as soon as their stock change.

I use Magento 2.4.6 with MSI and stock set to “update on save”.

I created two source items through the REST API.

They do show up in the base:

> select sku from catalog_product_entity where entity_id = 1529651 ;
+------------+
| sku        |
+------------+
| X2ERT7XZPF |
+------------+

> select * from inventory_source_item where sku = 'B1ERT7XZPF' ;
+----------------+-------------+------------+----------+--------+
| source_item_id | source_code | sku        | quantity | status |
+----------------+-------------+------------+----------+--------+
|      546978742 | mysource    | X2ERT7XZPF |  10.0000 |      1 |
|      547067016 | mysource2   | X2ERT7XZPF |  42.0000 |      1 |
+----------------+-------------+------------+----------+--------+

However, cataloginventory_stock_status and cataloginventory_stock_item show the product as out-of-stock:

> select * from cataloginventory_stock_status where product_id = 1529651 ;
+------------+------------+----------+--------+--------------+
| product_id | website_id | stock_id | qty    | stock_status |
+------------+------------+----------+--------+--------------+
|    1529651 |          0 |        1 | 0.0000 |            0 |
+------------+------------+----------+--------+--------------+

> select qty, is_in_stock from cataloginventory_stock_item where product_id = 1529651 ;
+--------+-------------+
| qty    | is_in_stock |
+--------+-------------+
| 0.0000 |           0 |
+--------+-------------+

I ran bin/magento indexer:reindex cataloginventory_stock but it didn’t change anything. What am I missing?