You are here:  » ean category mapping


ean category mapping

Submitted by marco on Fri, 2017-10-27 15:27 in

Hello,

I have a lot of merchants with very high level categories (unable to map with Category Hierarchy Mapping)
This results on the category pages with lots of products without Compare prices and lowest price.
Most products have EAN so i am using the Automatic Product Mapping by Unique ID.
Could the automatic mapping be adjusted so that not only the name but also the category is the same (used from the products that have a categoryid)?

Best Regards,
Marco

Submitted by support on Sat, 2017-10-28 08:54

Hello Marco,

Sure - if you edit scripts/uidmap.php and look for the following code at line 79 where the main update query is made to apply the mapping;

      mysqli_query($link2,$sql2);

...and REPLACE with:

      mysqli_query($link2,$sql2);
      $sql2 = "SELECT categoryid FROM `".$config_databaseTablePrefix."products`
                 WHERE name='".database_safe($product["name"])."' AND categoryid <> '0' LIMIT 1";
      $result2 = mysqli_query($link2,$sql2);
      if ($row2 = mysqli_fetch_array($result2,MYSQLI_ASSOC))
      {
        $sql2 = "UPDATE `".$config_databaseTablePrefix."products`
                   SET categoryid = '".$row2["categoryid"]."'
                     WHERE name='".database_safe($product["name"])."'";
        mysqli_query($link2,$sql2);
      }

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Sat, 2017-10-28 14:11

Hello David,

Somehow the (SELECT..) part does not work (when i replace this with a fixed number the categoryid gets updated).
I just cannot figure out why it does not? Any ideas?

Best Regards,
Marco

Submitted by support on Sat, 2017-10-28 14:42

Hello Marco,

Replacement updated above without sub-query so no mode / configuration dependencies...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Sat, 2017-10-28 15:38

Thanks!

Submitted by marco on Sat, 2017-11-04 10:33

Hello David,

Just found out that not all products are ean mapped any longer. It does work with the unmodified uidmap.php.
Is it possible to run a separate script to map the categories after uidmap.php? Or an other solution to handle this?

Best Regards,
Marco

Submitted by support on Mon, 2017-11-06 08:35

Hi Marco,

Sure - have a go with the following code as scripts/uidchmap.php

<?php
  set_time_limit
(0);
  require(
"../includes/common.php");
  if (!
$config_uidField) die("No \$config_uidField set in config.advanced.php");
  
$sql "SELECT `".$config_uidField."`,`categoryid` FROM `".$config_databaseTablePrefix."products`
            WHERE `"
.$config_uidField."` <> '' AND `categoryid` <> '0'";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $row)
    {
      
$sql "UPDATE `".$config_databaseTablePrefix."products` SET `categoryid`='".$row["categoryid"]."'
                WHERE `"
.$config_uidField."`='".database_safe($row[$config_uidField])."'";
      
database_queryModify($sql,$result);
    }
  }
  print 
"Done.\n";
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by marco on Mon, 2017-11-06 15:41

Many thanks!