Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Ampersand Symbols showing in attributes after upgrade & - &
 
Patrix
Jr. Member
 
Total Posts:  28
Joined:  2009-11-27
 

Hi,
after I upgraded to magento 1.6 I have an issue with the attributes.

When I save a new value for an attribute, (for example Name & Name) - it saves properly.
when I add another value to the same attribute, all the & become & amp;

Also, in the frontend, the & shows as & amp;

I fixed this issue in the past with the “Allow HTML-tags on Front-end” for the attribute, but it seems that it is no longer available since magento 1.4.

any idea???
I’m getting crazy!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tractorcow
Jr. Member
 
Total Posts:  2
Joined:  2011-11-13
 

I’m having the same issue. I’ve managed to reproduce this via the CMS.

- Create an attribute of type ‘select’
- Add an option with an ampersand in it. E.g. “A & L”
- Save this attribute

The “A & L” becomes “A & L”. Saving this attribute again without modifying any of the values re-encodes the ampersand so that the result becomes “A & L”.

Since we have automated importers many of these attributes are saved with no human intervention. I can write code in these importers to mitigate the symptoms, but it would be far better to attack the core problem. I suspect that even adding options to a select attribute triggers a re-encode on all attributes which should not otherwise need re-saving.

Note: This forum seems to have a similar HTML-encoding issue. Wish it wouldn’t encode my html escaped code for me. >_>

 
Magento Community Magento Community
Magento Community
Magento Community
 
tractorcow
Jr. Member
 
Total Posts:  2
Joined:  2011-11-13
 

My kind friend found a stop-gap solution to this.

Line 168 of /app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php

If we comment out $label = $helperCatalog->escapeHtml($label) or the loops surrounding it then that ‘fixes’ the issue.

Unfortunately this is a controller file, so you can’t just create a copy in local to override it, we would have to replicate it in our module and then override the route.

I commented out the function call to prevent the attributes being encoded again. It looks like the old code used ->stripTags instead of ->escapeHtml, which by default didn’t html encode the text. Perhaps the older code should have been kept.

Hope this helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Patrix
Jr. Member
 
Total Posts:  28
Joined:  2009-11-27
 

Hi Tractorcow,
thanks a lot!!!
That fixed the issue.

Hopefully this will be fixed with the next release.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Patrix
Jr. Member
 
Total Posts:  28
Joined:  2009-11-27
 

Another small update:

In order to fix the frontend, I replaced this line

<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>

with

<th class="label"><?php echo $this->stripTags($this->__($_data['label'])) ?></th>

under: app/design/frontend/default/yourtemplate/catalog/product/view/attributes.phtml

 
Magento Community Magento Community
Magento Community
Magento Community
 
ehagglebids
Jr. Member
 
Total Posts:  14
Joined:  2011-10-12
 
Patrix - 13 November 2011 09:40 PM

Another small update:

In order to fix the frontend, I replaced this line

<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>

with

<th class="label"><?php echo $this->stripTags($this->__($_data['label'])) ?></th>

under: app/design/frontend/default/yourtemplate/catalog/product/view/attributes.phtml

I am Having the same problem. What file is the above change made in.How do I comment out. I am a new to magento. What is the fix?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
gmgarcia53
Jr. Member
 
Total Posts:  19
Joined:  2011-01-28
 

Hello,

Thanks for the information; it was very helpful.

Here is some more reference:

http://www.gravitywell.co.uk/blog/post/magento-how-to-fix-double-ampersand-in-product-attributes-in-version-16

Thanks,

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top