0

how to get children product SKU or children product id using parent product id or SKU I have these details for particular options, here are 2 arrays and I need particular product id or sku

 Array
    (
        [0] => Array
            (
                [value_index] => 5438
                [label] => Black
                [product_super_attribute_id] => 531
                [default_label] => Black
                [store_label] => Black
                [use_default_value] => 1
            )
    
        [1] => Array
            (
                [value_index] => 5907
                [label] => Silver
                [product_super_attribute_id] => 531
                [default_label] => Silver
                [store_label] => Silver
                [use_default_value] => 1
            )
    
    )

Note: I am using AMP so can not use Jquery

2
  • Is this configurable product or what array? Aug 14, 2021 at 5:42
  • @DhirenVasoya yes it is configurable product Aug 16, 2021 at 5:51

1 Answer 1

0

Try following code.

$configurableProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);
     
    $_children = $configurableProduct->getTypeInstance()->getUsedProducts($configurableProduct);
    foreach ($_children as $child){
        echo $child->getID();
    }

NOTE: According to magento standard, do not allowed the use of Object Manager method, so implement the code by magento way.

Your Answer

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

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