Question

I am looking into getting the active simple products of configurable products in the cart.

Example: Imagine I have a t-shirt with different sizes and colours.

If somebody chooses a green large t-shirt, I want to be able to get the simple product ID's of green and large.

I can get all the possible simple products of a configurable product (small, medium, large, green, blue, red), but I would like to only get the ID's, or objects of the Large and Green simple products.

Is there a way of achieving this, in an observer file?

Was it helpful?

Solution

To get child product in cart for a configurable product. You can visit Block Mage_Checkout_Block_Cart_Item_Renderer_Configurable, it has a method getChildProduct which returns object of associated child product of the Configurable product you have added in cart.

For Example to print child product's ID in cart you can write such code somewhere under <dl class="item-options"> in file {theme}/template/checkout/checkout/cart/item/default.phtml

<?php 
$child = $this->getChildProduct();
echo $child->getId();
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top