문제

I've added the brand logo in the product view phtml file like this:

<div>
<?php $brand=$_product->getAttributeText('brand');
echo '<img src="media/catalog/brand/'.str_replace(' ', '_',$brand).'.png" alt="'.$brand.'">' ?>
</div>

It returns the correct url, for example for "acme" brand the resulting url is:

media/catalog/brand/acme.png

I tried to add the same code in the catalog/product/list.phtml file, but the link is broken and the generate url is:

media/catalog/brand/.png

So it seems like the brand attribute is not extracted. What's wrong?

도움이 되었습니까?

해결책

Make sure you set the value for 'Use in product listing' to 'Yes' on the attribute 'brand'.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top