This tutorial will guide you on how to get parent product id for simple product in magento. There are several ways we can achieve this.
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
->getParentIdsByChild($product->getId());
if (isset($parentIds[0])) {
// If we find a parent product then we display it's ID
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $parentProduct->getId();
}
OR
$simpleProductId = 102;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
->getParentIdsByChild($simpleProductId);
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $product->getId();
Best of luck
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
->getParentIdsByChild($product->getId());
if (isset($parentIds[0])) {
// If we find a parent product then we display it's ID
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $parentProduct->getId();
}
OR
$simpleProductId = 102;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
->getParentIdsByChild($simpleProductId);
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $product->getId();
Best of luck