简体   繁体   中英

Adding thumbnail image of product in Magento Order View Page in Backend

I am trying to show image thumbnail of products in order view page ( sales_order / view ) area of Magento. Adding preview image of the product as a column.

I have my line as the below:

load($_item->getProductId()); ?>init($_product, 'thumbnail')->resize(75, 75); ?>"   
alt="<?php echo $this->htmlEscape($_product['name']); ?>" border="0" width="75" />

But this just pulls through a blank box with no image at all in it, not even the Magento default image.

It will likely just be name of field or attribute slightly off? Or maybe even casing? But can't really see what I'm doing wrong.

If I replace:

load($_item->getProductId());

with:

load($_item['product_id'])->getData('image')

I can pull in the location of the image which shows on the page. But can't get it to work to actually display the image.

Can pull thumbnail of product in fine on the product grid page, but can't locate page to replicate code from.

Any help to polish off above would be appreciated.

Final code was the below. To get this working add it to /app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml

<td class="a-center">
  <?php $product = Mage::getModel('catalog/product')->setStoreId($_item->getOrder()->getStoreId())->load($_item->getProductId());?>
  <p align="center">
  <img src="<?php echo Mage::helper('catalog/image')->init($product, 'small_image')->resize(75); ?>" width="75" height="75" />
  </p>
</td>

You can show ordered item image with below code

$order   = Mage::getModel('sales/order')->load($orderId);    
foreach($order->getAllItems() as $item){    
    $product=Mage::getModel('catalog/product')->load($item->getProductId());
    echo  Mage::helper('catalog/image')->init($product, 'small_image')->resize(50,50);
}

this can be helpful for you i think you just need to place your attribute value

http://magentocodes.blogspot.in/2013/01/get-custom-attribute-value-in-magento.html

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