here is my code.
$storeId = Mage::app()->getStore()->getId();
$session = Mage::getSingleton('checkout/session');
foreach($session->getQuote()->getAllItems() as $item)
{//how to find parent id here}
At the above mentioned comment I want to access parent id of that particular product. Please Help ..
Try below code, may be it will help you
if($item->getTypeId() == "simple"){
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($item->getId()); // check for grouped product
if(!$parentIds)
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($item->getId()); //check for config product
}
You can use this to get the parent
foreach(...) {
$parents = $item->getTypeInstance()->getParentIdsByChild($item->getId());
//if you need to load the parent
if(!empty($parents)) {
$parentProd = Mage::getModel('catalog/product')->load($parents[0]);
//do something
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With