Home » Magento

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

20 July 2010 Share/Bookmark

A configurable product can have multiple other products associated to it.

Here is the code to fetch all the children products that are associated with a configurable product.

Here goes 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);

Hope this helps. Thanks.

From Mukesh Chapagain's Blog, post Magento: How to get all associated children product of a configurable product?

email

php magento mukesh chapagain

Get New Post by Email
RSS Feed Subscribe RSS Feed
  • Alok

    Hi Mukesh,

    for a configurable product, not all the child product id are coming.
    please help me for this situation.

    Thanks,
    Alok

  • riti

    Hi,

    How can I sort all child products based on attribute.

    $childCollection = Mage::getModel(‘catalog/product_type_configurable’)->addAttributeToSort(‘weight’, ‘asc’);

    $childProducts = $childCollection->getUsedProducts(null,$_product);

    OR

    $childCollection = Mage::getModel(‘catalog/product_type_configurable’);
    $childProducts = $childCollection->getUsedProducts(null,$_product);
    $childProducts = $childCollection->addAttributeToSort(‘weight’, ‘asc’);

    I have tried both the solutions but nothing works.
    Can you help!

    Thanks,
    Riti

  • http://www.i-avion.com vincent

    Hi, I’ve tried all 3 functions and noticed that if the id’s of the simple products have a range from for example 2000 t0 2400 and the configurable product associated has the id 2250 then these methods will only return the simple products from 2251 to 2400.

    Has anyone else noticed this too, is there a way to solve it ?
    thanks for your help

  • Hoang Vjet

    hi ! please help
    $product = Mage::getModel(‘catalog/product’)->load(54); // okie
    Mage::getModel(‘catalog/product_type_configurable’)->getUsedProducts(null,$product);  //error
     print_r($childProducts);  

    thank

  • http://www.facebook.com/people/Ashley-Messer/100002081662385 Ashley Messer

    How do you get the children of a configurable using the SOAP api that magento has?

  • Ravi

    Hello.. I want associate product of group products in list page… is there any method to do same ??

  • Dhara

    Hie. Can you please describe how to fetch particular data from the associative products? E.G. How to fetch the image or stock items of associative products?

  • Dhara

    Hie. Can you please describe how to fetch particular data from the associative products? E.G. How to fetch the image or stock items of associative products?

  • Dhara

    Hie. Can you please describe how to fetch particular data from the associative products? E.G. How to fetch the image or stock items of associative products?

  • http://www.facebook.com/rohitdoll Rohit Dhiman

     Same problem for me

  • Hell_dude

    in magento 1.6.2.0 (m.b. in latest version too) use Mage::getModel(‘catalog/product_type_grouped’)