Get child product in Magento

Hello All,

I am writing here a script for getting all the child products of the required parent product id

$productId = '123';
$product = Mage::getModel('catalog/product')->load($productId); //$productId for which the child products to be found        
$childids = $product->getTypeInstance(true)->getChildrenIds($productId, false);
echo '<pre>';
	$allProds = array();
	foreach($childids as $k => $v)
		foreach($v as $pid)
			$allProds[] = $pid;

echo '</pre>';

Hope this is useful

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top