A client requested adding product thumbnail images in the Order Confirmation Email that is sent after a customer order a product.. Without much ado here's the code...
<?php //added for sending image with order
$product = Mage::getModel('catalog/product')
->setStoreId($_item->getOrder()->getStoreId())
->load($_item->getProductId());
?>
<p align="center"><img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(50); ?>" width="50" height="50" alt="" /></p>
add this snippet below <td align="left" valign="top" style="padding:3px 9px">
NOTE: Don't forget to allow Display of Image in your email client (mine is gmail)
<?php //added for sending image with order
$product = Mage::getModel('catalog/product')
->setStoreId($_item->getOrder()->getStoreId())
->load($_item->getProductId());
?>
<p align="center"><img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(50); ?>" width="50" height="50" alt="" /></p>
add this snippet below <td align="left" valign="top" style="padding:3px 9px">
NOTE: Don't forget to allow Display of Image in your email client (mine is gmail)
hello
ReplyDeleteI have a question in the same context. Would appreciate if you could answer.
I have similar php code like this which i want to send in order confirmation.I put the code in cms/default/emailordershippingblob.phtml
My issue is when i am calling this block within the email template nothing is getting picked.
What should I do so that the php code is picked up in the email template??
thx
Great - very useful snippet. How would you add images to the shipping confirmation too?
ReplyDeleteThank you for this. I have an issue, however. After I set my secure base URL in the admin, now the email image references come over as https://. Outlook 2007 didn't show me the images, though the images were there, because it did not ask me to allow secure content. Why are the images being referenced to pull from https://?
ReplyDeleteThank you for sharing this! It seems that it will not work in 1.7 with configureable products. Any ideas or my mistake?
ReplyDeleteI am new to this I dont know were to insert it.... can u please explain
ReplyDeleteEach load of a product is heavy for performance, a better solution is :
ReplyDelete$_product = $this->getItem()->getProduct(); $this->helper('catalog/image')->init($_product, 'small_image')->resize(100);
Great solution.
DeleteI have been trying to get this code to work. Both the original and the last one seems to work but there are big problems. The first shows an image, the second just a place for the picture- ?. The first image is always the same whatever product I am choosing.
ReplyDeleteHas anybody an idea of what could be wrong. I am on 1.8.1.0, thanks
I am new to this I dont know were to insert it.... can u please explain
ReplyDelete