This question already has an answer here:

I'm very new in Magento. I want to display products images on page sales/order/view. How can I do that? Anyone can help? Thank you!

marked as duplicate by Jai, Aasim Goriya, HelgeB, Mohit Kumar Arora, Shoaib Munir Jun 19 at 9:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


For item image try with below code

step1 :


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<module name="Adamsmage_SalesOrder" setup_version="1.0.0">

Step2 :

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<preference for="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"

step3 :

<?php #app/code/Adamsmage/SalesOrder/Block/Item/Renderer.php

namespace Adamsmage\SalesOrder\Block\Item; 
use Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer as DefaultRenderer;

class Renderer extends DefaultRenderer{
 protected $string;

 * @var \Magento\Catalog\Model\Product\OptionFactory
protected $_productOptionFactory;

 * @var \Magento\Catalog\Block\Product\ImageBuilder
protected $imageBuilder;

 * @param \Magento\Framework\View\Element\Template\Context $context
 * @param \Magento\Framework\Stdlib\StringUtils $string
 * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory
 * @param array $data
public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Framework\Stdlib\StringUtils $string,
    \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory,
    \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder,
    array $data = []
) {
    $this->imageBuilder = $imageBuilder;
    parent::__construct($context, $string, $productOptionFactory, $data);

 * Get item product
 * @return \Magento\Catalog\Model\Product
 * @codeCoverageIgnore
public function getProduct()
    return $this->getItem()->getProduct();

 * Identify the product from which thumbnail should be taken.
 * @return \Magento\Catalog\Model\Product
 * @codeCoverageIgnore
public function getProductForThumbnail()
    return $this->getProduct();

 * Retrieve product image
 * @param \Magento\Catalog\Model\Product $product
 * @param string $imageId
 * @param array $attributes
 * @return \Magento\Catalog\Block\Product\Image
public function getImage($product, $imageId, $attributes = [])
    return $this->imageBuilder->setProduct($product)
} }

step4 :


echo $block->getImage($block->getProductForThumbnail(), 'cart_page_product_thumbnail')->toHtml();




__DIR__ );


<?php return array ('modules' =>array ('Adamsmage_SalesOrder' => 1,
  • Thanks for your answer! I have read it. I also read other documents and they said we shouldn't modify directly file config.php. Could you explain about that???? – Michael Tao Jun 19 at 9:14
  • run command like : php bin/magento setup:upgrade, php bin/magento setup:static-content:deploy – Anas Mansuri Jun 19 at 9:15

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