cancel
Showing results for 
Search instead for 
Did you mean: 

How to show product image for ordered items on admin panel order view

SOLVED

How to show product image for ordered items on admin panel order view

I have a magento store on magento version 2.1.7.

 

I want to show product image for ordered items on order view page admin panel.

 

Please help me to achieve this as I am new on magento 2.x developing..

4 REPLIES

Re: How to show product image for ordered items on admin panel order view

Hi @santoshcbonline,

 

I didn't tried this module but it seems can be useful for you: https://marketplace.magento.com/vsourz-order-success.html

 

You can always can perform a search at the marketplace: https://marketplace.magento.com/

 

Before installing a 3rd-party module remember to backup your database to be able to restore your store in case of troubles.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: How to show product image for ordered items on admin panel order view

I do not want product image to show on order success page on frontend.

 

Rather I want to show product images for ordered items on admin panel when admin view the order.

 

I want product images of ordered items along with product name and sku on order view page on admin panel.

 

Currently it only shows the product name and sku.

Re: How to show product image for ordered items on admin panel order view

Hi @santoshcbonline

 

Some one on stack exchange already tried this kind of solution !!

 

here if the link - https://magento.stackexchange.com/questions/106556/how-to-display-product-image-in-sales-order-view-...

 

This might help you 

if issue solved,Click Kudos & Accept as Solution

Re: How to show product image for ordered items on admin panel order view

Hello @santoshcbonline

 

you need to edit below file 

/vendor/magento/module-sales/view/adminhtml/templates/order/view/items/renderer/defult.phtml ( you need to copy into your theme or module)

 

replace file code with below code

<?php /** @var \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer $block */ ?>
<?php $_item = $block->getItem() ?>
<?php $block->setPriceDataObject($_item) ?>
<tr>
    <?php $i = 0;
    $columns = $block->getColumns();
    $lastItemNumber = count($columns) ?>
	<td>
	<?php $product =  $_item->getProduct();?>
	<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();?>
	
	<?php  $imagewidth=200;
	$imageheight=200;
	$imageHelper  = $objectManager->get('\Magento\Catalog\Helper\Image');
	$image_url = $imageHelper->init($product, 'small_image')->setImageFile($product->getSmallImage())->resize($imagewidth, $imageheight)->getUrl();
	 ?>
	 <img src="<?php echo $image_url;?>" />
	</td>
	 <?php foreach ($columns as $columnName => $columnClass):?>
        <?php $i++; ?>
        <td class="<?= /* @noEscape */ $columnClass ?><?= /* @noEscape */ ($i === $lastItemNumber ? ' last' : '') ?>"><?= /* @escapeNotVerified */ $block->getColumnHtml($_item, $columnName) ?></td>
    <?php endforeach; ?>
</tr>

Hope it will help you.

 

If it will work then give kudos or mark as solution