You are here:  » sql querry to remove/replace apostrophe from db?

Support Forum



sql querry to remove/replace apostrophe from db?

Submitted by GemViper on Sat, 2010-05-08 08:42 in

Hi David,

I'm trudging through the product matching for over 150,000 items and I keep running into the same scenario where Men's and Mens or Women's and Womens only partially match each other.

I say partially because on the product pages stores offering either version show up together but on search results pages the items are treated as different with only the ' character being different.

Would an sql command to remove the apostrophe from all titles be the best option or is there a better way? If SQL works best what should the query be?

Thanks again,

Gem

Submitted by support on Sat, 2010-05-08 09:51

Hi Gem,

It would be easiest (and avoids having to add filters to every single feed) to remove the apostrophes during import, immediately before the normalsied version of the product name is created. In includes/admin.php, look for the following code starting at line 271:

    /* create normalised version of product name for use in URLs */
    $normalisedName = tapestry_normalise($importRecord["name"]);

...and REPLACE with:

    $importRecord["name"] = str_replace("'","",$importRecord["name"]);
    /* create normalised version of product name for use in URLs */
    $normalisedName = tapestry_normalise($importRecord["name"]);

Cheers,
David.

Submitted by GemViper on Sat, 2010-05-08 18:20

I had a feeling there was an easier way, buying this script is giving me a great refresher on php code too. I'm sorry about taking advantage of the awesome level of support you offer but I hope at least some of my questions give you feature ideas for future releases :-)

Thanks again
Gem

Submitted by blogmaster2003 on Wed, 2010-05-12 18:51

If i want to remove or replace more than just the '

for example :

can i put like this?

$importRecord["name"] = str_replace(":","",$importRecord["name"]);

and for ,

$importRecord["name"] = str_replace(",","",$importRecord["name"]);

or can i put all in one line?

Submitted by support on Wed, 2010-05-12 18:53

Hi,

Yes - you can do it all on one line like this:

 $importRecord["name"] = str_replace(array(":",","),"",$importRecord["name"]);

Cheers,
David.