简体   繁体   中英

How to add product thumbnail image to order review page in Magento?

I am trying to show image thumbnail of products in order view page. For this I am using this line

<img src="<?php echo Mage::helper('catalog/image')
->init($_item,'small_image')
->resize(50); ?>" width="50" height="50" alt="" />

in this file

template/sales/order/items/renderer/default.phtml

what I get is the blank image of magento, this one --> 在此输入图像描述

On firebug I get the image url as below

src="http://my_Website.com/media/catalog/product/cache/1/small_image/50x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">

this is where that blank image is coming from.

Can anyone explain what's happening here and what's the possible solution.

Thank You very much in advance.

Try the codes given below:

First load the product

$_product = Mage::getModel('catalog/product')->load($_item->getProductId()); 

Then show the thumbnail where you want using the code given below

<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75, 75); ?>" alt="<?php echo $this->htmlEscape($_item->getName()); ?>" border="0" width="75" />

This code is working fine try :

if($_item->getProductType() == 'configurable') {
    $_product = $_item->getProduct();
}else{
    $_product = Mage::getModel('catalog/product')->load($_item->getId());
}

?>
<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="" />

Make sure you have checked the appropriate radio button on the products media tab. There are three columns (Base Image, Small Image, Thumbnail) that need to be set to use that image as a thumbnail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM