0

I have a configurable product and I want to capture the data of the associated product which is added to cart.

http://manoolia.dmcs-online.com/zig-zag-configurable?___store=english&___from_store=english

On this example, when you chose green and add it to cart, a popup will display with the red image(configurable product image). I want to get the associated product image etc.

Any idea?

1

If you want to show simple product thumbnail in shopping cart than you can change configuration on below path:

you will find this option in shopping cart section as define below.

system->configuration->sales->checkout->shopping cart tab.

system->configuration->sales->checkout->shoppingcart

| improve this answer | |
  • If you found answer helpful than please accept it. – Hardik Shah Jan 23 '15 at 15:20
  • Thanks, but although similar, this is not what I wanted. – Klevis Miho Jan 23 '15 at 15:37
0

Have a look in Mage_Sales_Model_Quote_Item_Abstract::getChildren, you should be able to use it to get the first child of a configurable which will be it's associated simple, then get whatever data you require.

Something like the following:

$helper = Mage::helper('catalog/image');

//However you get the quoteItem, it goes here!
$quoteItem = Mage::getModel('sales/quote_item');

$imageUrl = $helper->init($quoteItem->getProduct(), 'small_image');

if ($quoteItem->getData('product_type') == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {

    $children = $quoteItem->getChildren();
    $childQuoteItem = reset($children);
    if ($childQuoteItem) {
        $imageUrl = $helper->init($childQuoteItem->getProduct(), 'small_image');
    }
}
| improve this answer | |
  • This code gets all children? – Klevis Miho Jan 23 '15 at 15:35
  • Calling reset on it will get the first child, which will be the simple of the configurable – Luke Rodgers Jan 23 '15 at 16:03
  • Tried your code but it throws an error. Also tried with $_product->getChildren() but doesn't get any. – Klevis Miho Jan 23 '15 at 17:59
  • Product get children willnae work. What error is thrown? – Luke Rodgers Jan 24 '15 at 0:11
  • Fatal error: Call to a member function setFinalPrice() on a non-object in /home/manoolia/public_html/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php on line 89 – Klevis Miho Jan 28 '15 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.