0

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>
0

I sorted this issue by using the following update.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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