Active forum topics

©2006-2017 IAAI Software

Contact Us Privacy Policy

Support Plus

Product Mapping by UID and product name

Submitted by marco on Tue, 2014-05-20 14:09.

Hello,

I have implemented the Automatic Product Mapping by UID mod. Depending on import the product names can change.

Would it be possible to prefer some merchants over others in the use of the product names? So that these products do not change names after import but keep the same name? Or is there another way of being able to keep the same product names (better for seo and some merchants just have far better names than others).

Best,
Marco

Submitted by support on Wed, 2014-05-21 09:00.

Hello Marco,

Sure - the code that builds the SQL to select the name to use is as follows, at line 44 of uidmap.php:

      $sql2 = "SELECT SQL_CALC_FOUND_ROWS name FROM `".$config_databaseTablePrefix."products` WHERE ".$config_uidField."='".database_safe($product[$config_uidField])."' ORDER BY name LIMIT 1";

To modify this to enable a list of merchants by priority from which to pick the name, REPLACE with, for example:

      $sql2 = "SELECT SQL_CALC_FOUND_ROWS name,CASE merchant
          WHEN 'Merchant A' THEN '1'
          WHEN 'Merchant B' THEN '2'
          WHEN 'Merchant C' THEN '3'
        ELSE '999' END AS priority FROM `".$config_databaseTablePrefix."products` WHERE ".$config_uidField."='".database_safe($product[$config_uidField])."' ORDER BY priority LIMIT 1";

Simply edit Merchant A, Merchant B etc. with your preferred merchants from which to pick the name used, in order of priority, adding to the list if required making sure of course the increment the "THEN" value for each one...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Wed, 2014-05-21 14:46.

Yes this helps
Thanks,
Marco

Submitted by tobyhage on Thu, 2017-08-10 17:34.

David,

I want this kind of functionality also, but then to use for the product description field instead of the product name. Is this possible?!

kind regards,

Toby.

Submitted by support on Fri, 2017-08-11 08:01.

Hi Toby,

You could do this with a query to get the preferred merchant's description during Phase 2. To give this a go with latest version of uidmap.php, look for the following code at line 71:

      print "Phase 2:".$product["name"]."\n";flush();

...and REPLACE with:

      print "Phase 2:".$product["name"]."\n";flush();
      $sql2 = "SELECT description,CASE merchant
          WHEN 'Merchant A' THEN '1'
          WHEN 'Merchant B' THEN '2'
          WHEN 'Merchant C' THEN '3'
        ELSE '999' END AS priority FROM `".$config_databaseTablePrefix."products` WHERE ".$config_uidField."='".database_safe($product["uid"])."' ORDER BY priority LIMIT 1";
      $result2 = mysqli_query($link2,$sql2);
      $product2 = mysqli_fetch_array($result2,MYSQLI_ASSOC);
      $description = $product2["description"];

And then the following code at (now) line 85:

      $sql2 = "UPDATE `".$config_databaseTablePrefix."products` SET name='".database_safe($product["name"])."',normalised_name='".database_safe($normalisedName)."',search_name='".database_safe($searchName)."' WHERE ".$config_uidField."='".database_safe($product["uid"])."'";

...and REPLACE with:

      $sql2 = "UPDATE `".$config_databaseTablePrefix."products` SET name='".database_safe($product["name"])."',normalised_name='".database_safe($normalisedName)."',search_name='".database_safe($searchName)."',description='".database_safe($description)."' WHERE ".$config_uidField."='".database_safe($product["uid"])."'";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by tobyhage on Sat, 2017-08-12 09:48.

Super! Thank you very much.