1

I am new to Magento and I am trying to find a way how to include a picture of the product the customer ordered from my website in the order confirmation email?

3 Answers 3

2

You have file: app/design/frontend/base/default/template/email/order/items/order/default.phtml

Copy this file to your package/theme and add this piece of code below of foreach:

<?php 
$_product = Mage::getModel('catalog/product')
                ->setStoreId($_item->getOrder()->getStoreId())
                ->load($_item->getProductId());
?>

Add this code to show image of product:

<img src="<?php echo Mage::getModel('catalog/product_media_config')
                 ->getMediaUrl($_product->getThumbnail()); ?>" 
 alt="<?php echo $_item->getName() ?>" />
2
  • Thank you for your reply! Where is app/design.../default.phtml is normally located in Magento admin panel? Thank you!
    – Kate
    Commented Jul 15, 2015 at 23:01
  • Is a magento filesystem design basis: blog.nodwell.net/wp-content/uploads/2013/07/…
    – osrecio
    Commented Jul 15, 2015 at 23:08
0

Maegento does not save product image on Sales Item model(Mage_Sales_Model_Order_Item) That why you cannot get image from sales item .

If you need then with out product Model load you cannot get it at email

So you need add below code at app/design/frontend/YourPackage/YourTheme/template/email/order/items/order/default.phtml

<?php 

$_product = Mage::getModel('catalog/product')
               $_product ->setStoreId($_item->getOrder()->getStoreId())

                ->load($_item->getProductId());
// check product id is exit or not
if($_product->getId()):
<img src="<?php echo Mage::getModel('catalog/product_media_config') ->getMediaUrl($_product->getThumbnail()); ?>" 
 alt="<?php echo $_pr->getName() ?>" />

endif;
?>
0

Get Image in sale order email

Please view below code :

  1. $_item = $block->getItem();
  2. $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  3. $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProductId());
  4. $imageHelper = $objectManager->get('\Magento\Catalog\Helper\Image');
  5. $image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getFile())->resize(100, 100)->getUrl();

End add : <img src="<?php echo $image_url; ?>" alt="" />


Good look !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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