Saturday, September 17, 2011

How to Get parent id of simple product associated to configurable product in Magento

A simple product is associated with a configurable product. You have the id of the simple product. Now, you need the id of the configurable product with which the simple product is associated.

Get parent product id, i.e. get id of configurable product from a simple product.

$_product = Mage::getModel('catalog/product')->load(YOUR_SIMPLE_PRODUCT_ID);
$parentIdArray = $_product->loadParentProductIds()->getData('parent_product_ids');
print_r($parentIdArray);

0 comments:

Post a Comment