2012-12-06 115 views
1

我想在list.phtml中包含一個自定義圖像屬性。 屬性包括使用的addAttribute方法catalog.xml中的產品集合:在list.phtml上顯示自定義圖像

<action method="addAttribute"><code>hover_image</code></action> 

如果我嘗試$ _product-> getHoverImage,我得到的URL罰款。 但是當我嘗試使用調整圖像大小:

$this->helper('catalog/image')->init($_product, 'hover_image')->resize(240,186) 

它不工作,我收到一個錯誤「影像文件沒有被發現。」

回答

2

我設法得到它用一個簡單的if語句工作:

<?php if($_product->getHoverImage()): ?> 
<?php echo $this->helper('catalog/image')->init($_product,'hover_image')->resize(240,186); ?> 
<?php endif; ?> 
相關問題