I’ve to show the product thumbnail image in Admin order overview page in Magento 2.3.2P2
I am looking to customize default.phtml file of vendor module.
/vendor/magento/module-sales/view/adminhtml/templates/order/view/items/renderer/default.phptml
my required code is as below –
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var MagentoSalesBlockAdminhtmlOrderViewItemsRendererDefaultRenderer $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 = MagentoFrameworkAppObjectManager::getInstance();?>
<?php $imagewidth=125;
$imageheight=125;
$imageHelper = $objectManager->get(‘MagentoCatalogHelperImage’);
$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’ : ‘’) ?>”>
<?= $block->getColumnHtml($_item, $columnName) ?>
</td>
<?php endforeach; ?>
</tr>
but I am worried that after changing in vendor folder shall affect the future upgrade.
Please suggest best way to achieve this.
I want something lke the below the image.
Also I need to make clickable the product name and it should be redirect on the respective product page of ordered items.