Magento: How to get all associated children product of a configurable product?

A configurable product can have multiple other products associated to it. This article shows how to fetch all the children products that are associated with a configurable product.

Here is the code:


/**
 * Load product by product id
 */
$product = Mage::getModel('catalog/product')
				->load(YOUR_PRODUCT_ID);

/** 
 * Get child products id (only ids) 
 */
$childIds = Mage::getModel('catalog/product_type_configurable')
				->getChildrenIds($product->getId());

/** 
 * Get children products (all associated children products data) 
 */
$childProducts = Mage::getModel('catalog/product_type_configurable')
				->getUsedProducts(null, $product);

/** 
 * Get children products as collection
 * And, select all attributes like name, description, price, etc.
 */
$childProducts = Mage::getModel('catalog/product_type_configurable')						
				->getUsedProductCollection($product)
				->addAttributeToSelect('*');

Hope this helps. Thanks.