Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Get grouped product id from child product
 
grazzt
Sr. Member
 
Total Posts:  106
Joined:  2010-02-28
 

Hello, I’m using magento 1.5.1.0 and I’m trying to get the grouped product id from an associated simple product that belongs to the grouped product. I use the code below to do the same with configurable products and it works:

$product Mage::getModel('catalog/product');
$product->load($productId);
$configurable_product_model Mage::getModel('catalog/product_type_configurable');
$configurableParentId $configurable_product_model->getParentIdsByChild($product->getId());

I tried the above code for grouped products by replacing “product_type_configurable” with “product_type_grouped” but it didn’t work… Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
grazzt
Sr. Member
 
Total Posts:  106
Joined:  2010-02-28
 

Nevermind, I had wrong variable names....stupid mistake! Anyway, in case someone else wants to do this, I post the code that works:

$product Mage::getModel('catalog/product');
$product->load($productId);
$grouped_product_model Mage::getModel('catalog/product_type_grouped');
$groupedParentId $grouped_product_model->getParentIdsByChild($product->getId());
 
Magento Community Magento Community
Magento Community
Magento Community
 
hmm1985
Jr. Member
 
Total Posts:  2
Joined:  2013-03-17
 

Thanks for provide me better answer this is very helpful for me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mrsdesigns
Jr. Member
 
Total Posts:  3
Joined:  2009-10-04
 

I am struggling with the same problem.  Can you tell which file you altered?
TIA

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top