How to get the child products id from a product id in magento 2.
I am saving the products with its custom attributes. And it saved successfully.
But
- I wish to check what type of product i have using a product id.
- If i have a simple product save the product as it is. But if it is a configurable product , I wish to get all the child products and need to assign the attributes to the child also.
So My question is How to check whether the product is simple or config ?
If it is configurable product, How to get its child product Ids?
Best Answer
This will get all child products (associated simple products) as an array of a configurable product by object manager.
You can also achieve it by creating Data.php class file in app/code/NameSpace/ModuleName/Helper
For more information click here.