Friday, November 18, 2011

Magento: Get parent id of simple product associated to configurable product


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

No comments:

Post a Comment