0

I have the code below to the view.phtml file and shows the manufacturer logo under the price. The problem is that if I have no manufacturer it shows me the symbol that there is no image (only in Chrome) How can I fix that?

<?php $_product = $this->getProduct();
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
echo '<a href="/catalogsearch/advanced/result/?manufacturer='.$manufacturerId.'&q='.$manufacturerName.'">' ?> 
<img src="/media/catalog/brand/<?php echo str_replace(' ', '_',$manufacturerId); ?>.jpg" alt="<?php echo $manufacturerName; ?>" title="<?php echo $this->__('For more of') ?>&nbsp;<?php echo $manufacturerName; ?>&nbsp;<?php echo $this->__('press here') ?>" /></a>

enter image description here

1 Answer 1

0

You need to add an if statement around your output to check your manufacturer attribute:

<?php
$_product = $this->getProduct();
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
?> 
<?php if ($manufacturerId) : ?>
<a href="/catalogsearch/advanced/result/?manufacturer=<?php echo $manufacturerId; ?>&q=<?php echo $manufacturerName; ?>">
<img src="/media/catalog/brand/<?php echo str_replace(' ', '_',$manufacturerId); ?>.jpg" alt="<?php echo $manufacturerName; ?>" title="<?php echo $this->__('For more of') ?>&nbsp;<?php echo $manufacturerName; ?>&nbsp;<?php echo $this->__('press here') ?>" />
</a>
<?php endif; ?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.