문제

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?

도움이 되었습니까?

해결책

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();
?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top