We use a email template with the following code. We want to extend this with the product image, but that does not seem to work.

<?php foreach ($this->getOutOfStockItems()->getData() as $item): ?>
<?php echo $item['name'] ?>
<?php endforeach ?>

I already tried <?php echo $item['image'] ?> But that does not seem to work.

How can I get the product image?


Try this:

<?php foreach ($this->getOutOfStockItems()->getData() as $item): ?>
    <?php echo $name  = $item['name']; ?>
    <?php echo $image = $item['image_url']; ?>
<?php endforeach; ?>


Try to print what you have in your object and look if you have this image like this:

<?php Zend_Debug::dump($this->getOutOfStockItems()->getData()); ?>

To load the product by the product ID:

$product = Mage::getModel('catalog/product')->load($product_id); 
|improve this answer|||||
  • Thanks! Sadly that does not seem to work. I do not get any result. – JGeer Dec 7 '17 at 17:01
  • Look my explanation – PЯINCƏ Dec 7 '17 at 17:05
  • Thanks, but there is no image. So I think I should get it using the sku, right? Can you help me out with the right code? – JGeer Dec 7 '17 at 18:47
  • Have you the productID in the getData() ?? – PЯINCƏ Dec 7 '17 at 18:49
  • Yes product ID is also in the getData, by 'product_id'. – JGeer Dec 7 '17 at 18:51

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.