Question

I have a string replace that removes the 'manufacturer' name from a product title. However, it does not work if the manufacturer name has an & (e.g. Dolce & Gabanna) in it. Can someone please suggest an edit to the below code to get it working?

CURRENT CODE in LIST.PHTML

<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<span class="product-title" style="font-weight:bold;"><?php echo $_product->getAttributeText('manufacturer');?></span><br/>
<span style="text-transform:none;font-size:10px;"><?php $lowermenu=strtolower($_product->getAttributeText('manufacturer'));
$manufacture=array($lowermenu,$_product->getAttributeText('manufacturer')); echo str_replace($manufacture,' ',$_helper->productAttribute($_product, $_product->getName(), 'name')); ?></span></a></a>
</h2>
Was it helpful?

Solution

I sorted this issue by using the following update.

$manufacturer=htmlspecialchars($_product->getAttributeText('manufacturer'))

This avoided the issues with the '&' within the manufacturer attribute.

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