0

I want to get Sku for selected options.

enter image description here

Above image i have select blue and M. So this options product sku get in magento 2.

Please Help me.

THANKS.

1

1 Answer 1

0

You can try this code to get the sku of any product:

$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);

But if you want to see the configurable product sku in frontend

Visit https://firebearstudio.com/blog/how-to-get-simple-products-of-configurable-product-in-magento-2.html

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.