Showing results for 
Search instead for 
Did you mean: 

How to include Product Image in Email

How to include Product Image in Email

I am trying to show Product image in the email along with order items, but I do not see images, I have tried to add following code in `default.phtml` template. I am not sure if its in correct order.


<?php $_store = $_order->getStore(); ?>
<?php $_imageHelper = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Catalog\Helper\Image'); ?>
<?php $_baseImageUrl = $_store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'catalog/product'; ?>
<?php if($childProd = current($_item->getChildrenItems())): ?>
<img src="<?= $_imageHelper->init($childProd->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">
<?php else: ?>
<img src="<?= $_imageHelper->init($_item->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">
<?php endif; ?>

I am using `if($childProd...)` for the configurable product.

In email I am only getting product price etc as shown in the image below:-

Screen Shot 2020-07-30 at 12.23.15 PM.png



Re: How to include Product Image in Email

Hi @johndoe86cd 


You can take reference from below example:-


to my template folder 


 and adding the image column there...

$_item = $block->getItem();$_order = $_item->getOrder();$_store = $_order->getStore();$_imageHelper = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Catalog\Helper\Image');$_baseImageUrl = $_store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'catalog/product';


and right below

<img src="<?= $_imageHelper->init($_item->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">
It may help you!
Problem Solved? Please click on 'Kudos' & Accept as Solution!

Re: How to include Product Image in Email



thank for your comment. I am using Claue theme, and there is no default.phtml file under this category >> "app/design/frontend/Mgs/claue/Magento_Sales/templates/order"


Do I need to modify the file in: 



Or do I need to modify the following template >>


If thats the file, please read my question, I already edited this template but did not help.





I think you copied your answer from StackOverflow, that answer is the one I posted in my question. Its not working...