0

I recently purchased some templates from theme forest. https://codecanyon.net/item/magento-custom-email-templates-pro/19175962?s_rank=2

installed on the server and all is working great, I noticed in the code the images (thumbnails) were not showing up.

The code looks like this here,

foreach ($wa_data['items'] as $key => $value) {
$vars = get_object_vars ($value);
$_product = Mage::getModel('catalog/product')
            ->setStoreId($value->getOrder()->getStoreId())
            ->load($value->getProductId());
$item = array(
  'url' => $_product->getProductUrl(),
  'imgUrl' => Mage::getModel('catalog/product_media_config')
                   ->getMediaUrl($_product->getThumbnail()),
  'name' => $value->getName(),
  'sku' => $vars['_data']['sku'],
  'description' => $vars['_data']['description'],
  'number' => $vars ['_data']['product_id'],
  'qty' => intval($vars['_data']['qty_ordered']),
  'price' => $wa_data['symbol'] . ' ' . intval($vars['_data']['base_price']),
  'total' => $wa_data['symbol'] . ' ' . intval($vars['_data']
['base_row_total']),
);
 $wa_data['items'][$key] = $item;
}

I'm wondering if there is an issue here,

'imgUrl' => Mage::getModel('catalog/product_media_config')
               ->getMediaUrl($_product->getThumbnail()),

on the image in the code it looks like this here,

<a href="<?php echo $_item['url']; ?>"><img src="<?php echo $_item['imgUrl'] ?>" alt="<?php echo $_item['name'] ?>" />

Can you please help me get these thumbnails working. I'm using Magento 1.9.3

Any help understanding what is would be highly appreciated

1 Answer 1

0

In this case is better to use Mage::getSingleton('catalog/product_media_config') instead of Mage::getModel('catalog/product_media_config').

But this code is working Mage::getModel('catalog/product_media_config') ->getMediaUrl($_product->getThumbnail())

You should check is product has thumbnail for store in admin panel.

4
  • I'm having a problem showing a configurable product with this code
    – gx2g
    Commented Jul 28, 2017 at 17:51
  • Can anyone give me some help on how to show the configurable product as well. this only works on single product images.
    – gx2g
    Commented Jul 28, 2017 at 19:08
  • I've checked this code with configurable products and it worked fine. $_product->getThumbnail() will get product image that is marked as "Thumbnail" for product. Please make sure that product from your list really have "thumbnail" images. If you want to get base image you can do this $_product->getImageUrl();
    – olkuznw
    Commented Jul 31, 2017 at 8:19
  • If you create an order for bundle product, single product and configurable product. you'll see that the configurable product is showing both images. so if I ordered the black, in the email the black and silver image show up. I'm testing configurable, bundle and single products in one order. there is some issues still
    – gx2g
    Commented Jul 31, 2017 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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