Magento 1.9 Cart – Get Bundle Parent and Children Product

bundle-productbundled-productcartmagento-1.9quote

When looking at the cart from code (for example in the checkout_cart_save_after event), how do I tell which items are part of bundles and which are not?

For example, lets say I have a bundle which is a pack of 4 shirts together with a discount, and those same shirts can also be purchased separately, as simple products.

Now a user added this bundle to cart + 2 of those shirts without any bundle.
If I look at the products in cart, by using something like this:

Mage::getModel('checkout/cart')->getQuote()->getAllItems();

I will get a total of 7 items – the bundle product, and 6 shirts.

How can I tell which of the shirts are part of the bundle and which were bought separately?

Thanks!

Best Answer

answering self for future seekers:

$item->getParentItemId()

source: http://davehiren.blogspot.co.il/2014/02/magento-get-cart-items-how-to-get.html

Related Topic