AI Reports

Magento 2 SQL queries › Stock

What's the total stock quantity in each source?

Short answer: With Magento's multi-source inventory, each warehouse is a source and quantities live in inventory_source_item.

In the Magento admin

  1. Go to Stores › Inventory › Sources to see the sources, then filter the product grid by Quantity per Source.

With one query

These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.

Works on Magento Open Source and Adobe Commerce:

SELECT isi.source_code,
       COUNT(*) AS skus,
       SUM(isi.status = 1) AS skus_in_stock,
       SUM(isi.quantity) AS total_qty
FROM inventory_source_item isi
GROUP BY isi.source_code
ORDER BY total_qty DESC;

Good to know

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn