You are here:  » Capitalization in Product Mapping

Support Forum



Capitalization in Product Mapping

Submitted by biglion on Thu, 2009-09-10 21:15 in

Is there a way to ignore upper case vs. lower case letters when matching product names?

While capitalization is useful for the product title display, I would like the products to match in the mapping without actually mapping each capitalized version... I would like Widget, WIDGET, widget, WIDget, etc. to all be the same product.

Submitted by support on Fri, 2009-09-11 08:23

Hi,

To make Product Mapping case insensitive; first look for the following code around line 368 of includes/admin.php

  $alternate = trim($alternate);

...and REPLACE this with:

  $alternate = strtolower(trim($alternate));

And then higher up the same file, look for the following code within the import record handler function starting at around about line 228:

    /* apply product mappings */
    if (isset($admin_importProductMappings[$record[$admin_importFeed["field_name"]]]))
    {
      $record[$admin_importFeed["field_name"]] = $admin_importProductMappings[$record[$admin_importFeed["field_name"]]];
    }

...and REPLACE that with:

    /* apply product mappings */
    if (isset($admin_importProductMappings[strtolower($record[$admin_importFeed["field_name"]])]))
    {
      $record[$admin_importFeed["field_name"]] = $admin_importProductMappings[strtolower($record[$admin_importFeed["field_name"]])];
    }

Hope this helps!

Cheers,
David.

Submitted by biglion on Fri, 2009-09-11 14:10

That seems to bypass many of the products that I have already mapped and puts the different versions back in the database.

Submitted by biglion on Fri, 2009-09-11 14:21

UPDATE: Actually, it looks like all of the products I had already mapped were not imported at all.

Submitted by support on Fri, 2009-09-11 14:50

Hi,

Could you email me your includes/admin.php as an attachment and I'll check it out...

Cheers,
David.

Submitted by biglion on Fri, 2009-09-11 19:11

Thanks, the updated code above seems to be working great.

Submitted by Keeop on Mon, 2009-09-14 16:01

Hi David,

Won't this result in the end product name being in lower case? Is there any other way of doing this to avoid that happening?

Cheers.
Keeop

Submitted by support on Mon, 2009-09-14 16:05

Hi Keeop,

It's only the comparison that is being made case insensitive (i.e. they keys into the $admin_importProductMappings array); the actual alternate product name, which is taken as the value of that array is applied exactly as it appears in the master product name...

Cheers,
David.

Submitted by Keeop on Mon, 2009-09-14 21:33

Hi David,

Is it?? Sorry, if there's one thing I hate it's arrays! I implemented this code but it didn't seem to work so I assumed it was changing the case of the record values which was then causing problems with some other stuff I do later on in the script with those values. OK, I'll have another look and try and see what's going on.

Cheers.
Keeop

Submitted by support on Tue, 2009-09-15 07:12

Hi Keeop,

Have a look at the print_r() function with the $admin_importProductMappings array which should indicate what's going on. Let's say a mapping had been created for the master product name "Blue Widget", with an alternatives of "Big Blue Widget", and "Widget Blue". With the keys being strtolower()'d by the modification, the array should contain:

$admin_importProductMappings["big blue widget"] = "Blue Widget"
$admin_importProductMappings["widget blue"] = "Blue Widget"

The product name being imported is then also strtolower()'d, and used to check that array, and if a value is found the product name field is overwritten with the master product name.

(I normally use exit(); immediate after debugging with print_r() so that you can view the first instance otherwise it will generate lots of output - once for every product being imported!)

Hope this helps!

Cheers,
David.

Submitted by philstone on Mon, 2011-04-04 11:54

Hi David

Trust your well

trying to sort out the product mapping at the minute,

i seem to have two instances of

$alternate = trim($alternate);

in my includes/admin.php, do both of these need changed?

regards

Phil Stone
www.buy24-7.net

Submitted by support on Mon, 2011-04-04 11:59

Hi Phil,

Yes sorry - the first instance refers to Category Mapping, so it's the second instance you want, which is at line 414 in the 11/09A distribution.

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Mon, 2011-04-04 12:11

hi David

super job, thanks!

regards

Phil Stone
www.buy24-7.net

Submitted by cfoss on Thu, 2011-07-28 01:49

Hi David - I am using the new 12/10B version, what changes do I need to make to my includes/admin.php to make this modification. I am not quite sure what do with the second set changes you noted above. Your help would be much appreciated - thanks!

Submitted by support on Thu, 2011-07-28 08:42

Hi,

To make Product Mapping case insensitive in 12/10B, first look for the following code at line 473:

          $alternate = trim($alternate);

...and REPLACE with:

          $alternate = strtolower(trim($alternate));

And then look for the following code at line 270:

    if (isset($admin_importProductMappings["=".$importRecord["name"]]))
    {
      $importRecord["name"] = $admin_importProductMappings["=".$importRecord["name"]];
    }

...and REPLACE with:

    if (isset($admin_importProductMappings["=".strtolower($importRecord["name"])]))
    {
      $importRecord["name"] = $admin_importProductMappings["=".strtolower($importRecord["name"])];
    }

...and finally look for this code at line 288:

              if (strpos($importRecord["name"],$word) !== FALSE) $found++;

...and REPALCE with:

              if (stripos($importRecord["name"],$word) !== FALSE) $found++;

Cheers,
David.
--
PriceTapestry.com

Submitted by cfoss on Thu, 2011-07-28 19:44

Thanks David! But does this only work for products that have been mapped using the "Product Mapping" tool?

Submitted by support on Thu, 2011-07-28 19:50

Hi cfoss,

It makes the process of applying Product Mapping case insensitive, but otherwise, the product grouping is, itself, not case sensitive anyway, so if you have the same products from different merchants called "RED WIDGET" and "Red Widget" they should compare.

If you're not sure, let me know the URLs of a couple of products on your site (I'll remove the URLs before posting your reply) that you want to be compared but are not being I'll take a look for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by cfoss on Thu, 2011-07-28 20:53

Ok, below are some URL's of a couple of the products I am having trouble with from two different merchants. I've pulled the feeds and they look normal, so I am not sure what the problem is. Also, I am not sure how extensive the problem is, a lot products work just fine, but I've noticed this problem on a handful of searches I have done. Let me know if you need access to my ftp site. Thanks for your help!

{link saved}

Submitted by support on Fri, 2011-07-29 09:24

Hi cfoss,

Yes there does seem to be some strange case sensitivity going on; I'll happily have a look by FTP for you if you'd like to email me the details I'll check it out right away...

Cheers,
David.
--
PriceTapestry.com