0

Hi there I am adding an image to order emails. So far I have managed to get the image inserted:

<?php $_item = $this->getItem() ?>
<?php 
$_product = Mage::getModel('catalog/product')
                ->setStoreId($_item->getOrder()->getStoreId())
                ->load($_item->getProductId());
?> 
<?php $_order = $this->getItem()->getOrder() ?>
<tr>
    <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
        <img src="<?php echo Mage::getModel('catalog/product_media_config')->getMediaUrl($_product->getThumbnail()); ?>" 
 alt="<?php echo $_item->getName() ?>" />
    </td>

But this produces a large image how can I get the thumbnail image or resize it to fit? I know I can resize it using the <img> tag but I'd rather call the smaller image first then resize.

1

Try this:

<?php $_item = $this->getItem() ?>
<?php 
$_product = Mage::getModel('catalog/product')
                ->setStoreId($_item->getOrder()->getStoreId())
                ->load($_item->getProductId());
?> 
<?php $_order = $this->getItem()->getOrder() ?>
<tr>
    <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(150,150); ?>" 
 alt="<?php echo $_item->getName() ?>" />
    </td>
 </tr>

OR

<?php $_item = $this->getItem() ?>
<?php $_product = $_item->getProduct();?> 
<?php $_order = $this->getItem()->getOrder() ?>
<tr>
    <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
        <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(150,150); ?>" 
 alt="<?php echo $_item->getName() ?>" />
    </td>
 </tr>
  • First solution worked perfectly. Cheers – Pragman Mar 23 '17 at 23:44
0

Use this code:

$thumbnail = Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(150,220);

Also here you can get product thumbnail without loading the product using this code:

$thumbnail = $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75);

I hope it will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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