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

Scenario:

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.

Note: This method is deprecated after 1.4.2.0


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

This is the working method.


$_productId = YOUR_PRODUCT_ID;
$parentIdArray = Mage::getModel('catalog/product_type_configurable')
                      ->getParentIdsByChild($_productId);

Hope it helps. Thanks.