Search code examples
magentomagento-1.4

How to get grouped product ID from purchased or cart product


I'm using grouped products to track promotions. Simple products will at times belong to multiple grouped products, so checking parentProductIds is of no use. I'm wondering how to track the grouped product ID when a product is purchased through the grouped (promotion) SKU. I can see it's being stored in info_buyRequest and super_product_config within the orders, but how do I get that information back out? And is there a way to get it out in the cart/quote?


Solution

  • I was able to get it with the following code in cart.phtml, in the foreach($this->getItems() as $_item):

    $values = unserialize($_item->getOptionByCode('info_buyRequest')->getValue());
    $parentId = $values['super_product_config']['product_id'];