Magento get simple product from configurable


Magento get simple product from configurable : As we know configurable products are collection of simple products. If we are working with magento we often need to get simple products from configurable products. You can get all child products of a configurable products using the configurable product’s id. Here we are going to explain the method to get all child items from configurable product.


Syntax : Magento get simple product from configurable

Here is the syntax for getting simple products from configurable products –

Magento get simple product from configurable

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

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

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

Pass the product id of the configurable product and get all child items data as above.


Advertisements

Add Comment

📖 Read More