Wanted to correct my earlier post.. Hypercoyote pointed out an error in the code posted by both Davewest and myself..

Originally Posted by
hypercoyote
So the code actually did work, although it has one error, it replaces 'gt' with 'qt' (a Q), so after fixing that, it seems to be working :)
Also in looking over this again, I realized that there may have been no reason to replace the original code in the sanitizer section.. just simply needed to add to it..
So here's the corrected code.. (Works with version 1.7.4 of Google Base Feeder module)
- To fix double quotation (") marks in product descriptions, AND product titles. (ie: 12-14" Widget)
- To correct ampersands (&) used instead of the word "and" in product descriptions.
In \includes\classes\google_base.php around line 202 find this:
PHP Code:
$str = str_replace(array("<", ">"), array("<", ">"), $str);
Replace that line with:
PHP Code:
// $str = str_replace(array("<", ">"), array("<", ">"), $str);
// 10-01-2009 Updated line 202 to include corrections for quotation marks and ampersands in product titles and descriptions
$str = str_replace(array("<", ">", "lt;", "gt;", "quot;", """, "amp;"), array("<", ">", "<", " > ", """, "\"", "&"), $str);

Originally Posted by
DivaVocals
Thanks Dave..
This was a HUGE help for me..
This fixed double quotation (") marks in my client's product descriptions, but not the product titles. (ie:
12-14" Widget) I also needed to add a fix for ampersands (&) used instead of the word "and" in product descriptions. So I modified your change slightly as follows:
In \includes\classes\google_base.php around line 202 find this:
PHP Code:
$str = str_replace(array("<", ">"), array("<", ">"), $str);
Replace that line with:
PHP Code:
// $str = str_replace(array("<", ">"), array("<", ">"), $str);
// 10-01-2009 Updated to correct quotation marks and ampersands in product titles and descriptions
$str = str_replace(array("lt;", "gt;", "quot;", """, "amp;"), array("<", " &qt; ", """, "\"", "&"), $str);
When I make these kinds of changes I like to comment out the original code versus simply replacing it and I always include comments so I know WHY I made the change.. (in case I have a senior moment!

) so if I need to roll back my change I can easily do this.
Like Dave said.. Nothing wrong with the code.. just with how my clients product titles and descriptions are managed needed a little massaging to make Google happy..

Originally Posted by
davewest
I format my descriptions and titles using HTML tags. I also use some tags to keep from having errors in MySQL server such as commas and quotation marks. I'm using the RSS 2.0 format for my Google feed which has problems with some HTML tags within xml. On top of it all, Google has it's own formatting you need to consider if you want your feed to display at all. Thus the need for sanitizing it.
Unfortunately, theirs not an easy one fix for all users solution, lest for my limited coding ability. All my quotations are tag as " and for some reason, the & is removed during sanitizing leaving me with quot; which errors in Google. My fix was with this line in \includes\classes\google_base.php Look for the function 'google_base_xml_sanitizer'
Code:
$str = str_replace(array("<", ">"), array("<", ">"), $str);
with this one
Code:
$str = str_replace(array("lt;", "gt;", "quot;"), array("<", " &qt; ", """), $str);
My quotation now shows up in titles and description.
Theirs nothing wrong with the code, just with how my titles and description are coded and my refusal to modify 3000 products just to please google.
Bookmarks