You are here:  » Product Mapping Keywords


Product Mapping Keywords

Submitted by MarkP on Thu, 2012-04-19 19:19 in

Hi David,

Is it possible with product mapping to be able to exclude for example “size 12 Ribbon” when I only want to show “Size 1 Ribbon” without having to use exact matches?

Submitted by support on Fri, 2012-04-20 13:22

Hi Mark,

It's straight forward to add negative keywords to Product Mapping. In includes/admin.php look for the following code around line 284:

foreach($words as $word)
{
  if ($word)
  {
    if (strpos($importRecord["name"],$word) !== FALSE) $found++;
  }
}

...and REPLACE with:

foreach($words as $word)
{
  if (substr($word,0,1)=="!")
  {
    if (strpos($importRecord["name"],substr($word,1)) !== FALSE)
    {
      $found = 0;
      break;
    }
  }
  elseif ($word)
  {
    if (strpos($importRecord["name"],$word) !== FALSE) $found++;
  }
}

"!" means "not" in many programming languages so it's a logical character to use; so as an alternative for this mapping use:

Size 1 Ribbon !12

Cheers,
David.
--
PriceTapestry.com

Submitted by MarkP on Fri, 2012-04-20 15:30

Hi David,

I have tried this but can't get it to work, it only returns one merchant even in I use "Size 1 Ribbon !zzz", When I use "Size 1 Ribbon" again the different merchant records come back.

Thanks
Mark.

Submitted by support on Fri, 2012-04-20 15:44

Sorry Mark, the negative match needs to be removed from the array for the count() test to work afterwards, please use:

foreach($words as $k => $word)
{
  if (substr($word,0,1)=="!")
  {
    if (strpos($importRecord["name"],substr($word,1)) !== FALSE)
    {
      $found = 0;
      break;
    }
    else
    {
      unset($words[$k]);
    }
  }
  elseif ($word)
  {
    if (strpos($importRecord["name"],$word) !== FALSE) $found++;
  }
}

Cheers,
David.
--
PriceTapestry.com

Submitted by MarkP on Fri, 2012-04-20 15:50

Hi David,

That works great....thanks for the help.

Mark

Submitted by Bakalinge on Tue, 2013-05-14 15:46

Hi David,

Which syntax would you use if you have to exclude many words from the same product name?

product name !word1 word2

or
product name !word1 !word2

or
product name !word1
product name !word2

Thanks !
Bak

Submitted by support on Tue, 2013-05-14 15:52

Hello Bak,

The second...

product name !word1 !word2

You can have as many negative keywords in a single Alternative expression as you want, position / order doesn't matter...

Cheers,
David.
--
PriceTapestry.com

Submitted by Bakalinge on Tue, 2013-05-14 16:14

Thanks David !