Magento 2 in how to get the configurable products related all child (simple products QTY) in list page using object manager?

Please give me a solution this questions?


you can get all simple products associate to configurable product:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);

$_children = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
foreach ($_children as $child){
echo "Here are your child Product Ids ".$child->getID()."\n";
echo "count: ".count($_children);
Its Working .

             $productId = 161;
              $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
              $currentproduct = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);                $configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);       
              $_children1 = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
              foreach ($_children1 as $child1) {
               echo $child->getsku();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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