Magento-2.1 – SQL Query to Get All Simple Product Quantities and SKUs

magento-2.1stock

I just don't know how to get all simple product's stock and SKU information with SQL Query. I just need to get something like this

SKU       Quantity   Stock Status
---       --------   ------------
454645       50           1
545878       15           1

Any help please.

Best Answer

Use following query :

"SELECT cpe.sku, csi.qty FROM catalog_product_entity cpe RIGHT JOIN cataloginventory_stock_item csi ON cpe.entity_id = csi.item_id GROUP BY cpe.sku ORDER BY cpe.sku ASC";

You can check in stock or out of stock according to the returned quantity