You are here:  » Addon at Alternatives position


Addon at Alternatives position

Submitted by stevebi on Mon, 2015-11-23 12:00 in

Hello David,

I would like to ask the following concerning Product Mapping -> Alternatives position

For every product code that I place (without using =) example "3G10120" I place it with "(3G10120)" or "[3G10120]" because they also exist this way at product names.

Is it possible to modify the code so either () or [] to be placed automatically for every product code that I place in order tomap the product?

And because I have already mapped a lot of products with () is it possible to check if already exists this format in order not to apply it twice example "((3G10120))"

Cheers

Steve

Submitted by support on Mon, 2015-11-23 13:46

Hi Steve,

This is based on your existing modification for whole word matching only - in includes/admin.php, where you currently have the following code at line 429:

  $searchWords = explode(" ",$nameToLower);

...and REPLACE with:

  $searchWords = explode(" ",$nameToLower);
  foreach($searchWords as $searchWord)
  {
    $searchWords[] = "(".$searchWord.")";
    $searchWords[] = "[".$searchWord."]";
  }

That will add an additional test for (keyword) or [keyword]...

Hope this helps!
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-11-23 13:53

Great help David,

Just a question.

Will their be any problem for the existing mappings that have either () or [] ?

Cheers

Steve

Submitted by support on Mon, 2015-11-23 14:57

Hello Steve,

Ah - I think I interpreted the question the wrong way round - (123) is what is already in the Product Name, and you want that to match if a keyword in a Product Mapping Alternatives list is just 123...

If that's correct, revert the above, and instead where you have the following code around line 450:

  if (in_array($word,$searchWords)) $found++;

...REPLACE with:

  if (
    (in_array($word,$searchWords))
    ||
    (in_array("(".$word.")",$searchWords))
    ||
    (in_array("[".$word."]",$searchWords))
   )
  {
    $found++;
  }

With regards to your last question - no problem if (123) Alternatives already exist - the code to perform the above conditionally would be no more efficient that simply checking for ((123)) anyway...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-11-23 21:26

Hello David,

This is what exactly I wanted.

I will apply it and test it

Thank you for the great support

Cheers

Steve