How to get product image and price in shipping email template.enter image description here

For image i add a code in shipping/default.phtml

$productId = $_item->getProductId();
$objectManagerHere = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManagerHere->get('Magento\Catalog\Model\Product')->load($productId);
$productImage = $this->helper('Magento\Catalog\Helper\Image')->init($product, 'category_page_list')->getUrl();

    <img height="80" width="80" src="<?= $productImage ?>" alt="<?= __('Product Image');?>">

but i get's only placeholder image

  $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $imageHelper  = $_objectManager->get('\Magento\Catalog\Helper\Image');
  $image_url = $imageHelper->init($product, 'product_thumbnail_image')->setImageFile($product->getFile())->resize($imagewidth, $imageheight)->getUrl();
  $priceHelper = $_objectManager->create('Magento\Framework\Pricing\Helper\Data'); 
  echo $priceHelper->currency($product->getFinalPrice(), true, false); 

It's will be helpfull

  • Hi, @arun I place your code, still image get's placeholder image and price set as "0.00" – Priya Mar 20 '19 at 12:05
  • Thank you @Arun, i listed image, but for my swatch products, it listed only parent image, i like ti get my selected child image. – Priya Mar 21 '19 at 9:16
  • 1
    magento.stackexchange.com/questions/174758/… . this link may be helpful mohana – Arunprabakaran M Mar 21 '19 at 9:22
  • 1
    Now getting the image working fine and getting a price is only your problem right? – Arunprabakaran M Mar 21 '19 at 9:26
  • 1
    Hi mohana .are you need to get child image or small image of simple product – Arunprabakaran M Mar 21 '19 at 9:41

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.