cancel
Showing results for 
Search instead for 
Did you mean: 

Color-specific product image in transactional email

Highlighted

Color-specific product image in transactional email

Hi all,

 

We're having some (simple) products, on where you can choose the color you're interested in. Then, when you select for example a raincoat in color yellow, the product image changes to the correct color. If the customer orders the coat, in the transactional email the wrong image shows up.

 

In my /public_html/app/design/frontend/base/default/template/email/order/items/order I already have:

 

if ($_item->getProductType() !== Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
    $parentIds = Mage::getModel('catalog/product_type_configurable')
                       ->getParentIdsByChild($_item->getProductId());  
    $_product = Mage::getModel('catalog/product')  
                       ->setStoreId($_item->getOrder()->getStoreId())  
                       ->load($parentIds[0]);
} else {
    $_product = Mage::getModel('catalog/product')  
                       ->setStoreId($_item->getOrder()->getStoreId())  
                       ->load($_item->getProductId());  
}

And

 

<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(135)->__toString(); ?>"  width="135" height="135" alt="<?php echo $_item->getName() ?>" />

But it still shows the wrong (color) image, though the SKU which is displayed in the email, is correspondig with the product with the correct image. I'm not very good with Magento, so I have absolutely no clue where to look now.

Can somebody please help me in the right direction?

Thanks in advance!