Home » Magento

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

20 July 2010 9,126 views Popularity: 19% Share/Bookmark

email

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.

Related posts:

  1. Magento: Get order option of configurable and bundle product in cart
  2. Magento: Get parent id of simple product associated to configurable product
  3. Magento: Get sub categories and product count
  4. Magento: Product Edit Warning: Invalid argument supplied for foreach()
  5. Magento: Load store specific product
  6. Magento: How to get product stock quantity & other stock information?
  7. Magento: Downloadable products not displayed in Associated Products tab in Grouped Product
  8. Magento: Get manufacturer name and id from product
  9. Magento: How to get top rated products?
  10. Magento: Get category name and url from product
  • 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?