当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How to make an image link to a product page in magento

问题描述:

I'm trying to make a product image link to the product page in magento. I have done this before with similar code but, for some reason this time it refuses to work. Any ideas would be greatly appreciated!

<td style="text-align: center; width: 25%; padding-right: 15px; >

<p><a href="<?php echo $_related->getProductUrl() ?>"><img src="<?php echo $this- >helper('catalog/image')->init($_related, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_related->getName()) ?>" /></a></p>

<h5><a href="<?php echo $_related->getProductUrl() ?>"><?php echo

$this->htmlEscape($_related->getName()) ?></a></h5>

</td>

网友答案:

I have tested below code which works for me

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img class="product-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(130, 170) ?>" width="130" height="170" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</a>
分享给朋友:
您可能感兴趣的文章:
随机阅读: