Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top