Reputation: 325
Can you suggest a php code in order to show the image of a related product
I am using this code in view.phtml
<?php $related_prods = $_product->getRelatedProductIds();
foreach($related_prods as $related){
$_rel = Mage::getModel('catalog/product')->load($related);
echo $_rel->getName() . " " . $_rel->getImageUrl();
} ?>
I am just getting the url of the image that I want but I want to show the image itself!
Can you suggest of something?
Upvotes: 0
Views: 1229
Reputation: 3097
<?php $related_prods = $_product->getRelatedProductIds(); ?>
<?php foreach($related_prods as $related): ?>
<?php $_rel = Mage::getModel('catalog/product')->load($related); ?>
<?php echo $_rel->getName(); ?>
<img src="<?php echo $_rel->getImageUrl(); ?>"/>
<?php endforeach; ?>
In other words: use the HTML <img>
-tag...
Upvotes: 1