I want to get all the qty total for all simple products linked to a specific configurable product I have to do the following (check my code below) but it returns "0" on total, can anyone help me, please?

1 Answer 1


Just try it for my case in list page it worked.

$totl_qty = 0;
            $configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($_product->getId());
            $_children = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
            foreach ($_children as $child){
                $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
               $totl_qty += $StockState->getStockQty($child->getId(), $child->getStore()->getWebsiteId());
     echo $totl_qty;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.