You are here:  » Mapping Query


Mapping Query

Submitted by philstone on Tue, 2012-12-18 00:18 in

Hi David

Hope all is well with you!

I was wondering about a little tweak for the productmap_helper.php file

At the minute I can search by ean/name/model etc to get results to display, is there a way that the same search could product a result below of any ean numbers associated to products using the search term as i think this could speed up the process of mapping more products by name?

Regards
Philip

Submitted by support on Tue, 2012-12-18 09:18

Hi Philip,

Have a go with something like this; in admin/productsmap_helper.php look for the following code at line 82:

  print "</select>";

...and REPLACE with:

  print "</select>";
  if ($resultCount)
  {
    $ins = array();
    foreach($rows as $row)
    {
      $ins[] = "'".database_safe($row["name"])."'";
    }
    $in = implode(",",$ins);
    $sql = "SELECT DISTINCT(ean) FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$in.")";
    if (database_querySelect($sql,$rows))
    {
      print "<h3>Associated EANs</h3>";
      print "<ul>";
      foreach($rows as $row)
      {
        print "<li>".$row["ean"]."</li>";
      }
      print "</ul>";
    }
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Tue, 2012-12-18 12:29

Hi David

Thanks for that!

I tried to use it there but it was giving me the following error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/buy247/public_html/electronics/includes/database.php on line 27

Line 27 of includes/database.php

while($row = mysql_fetch_array($result,MYSQL_ASSOC))

regards

Phil Stone
www.buy24-7.net

Submitted by support on Tue, 2012-12-18 12:37

Hi Phil,

Could you enable database debug mode by changing line 6 of config.advanced.php as follows;

  $config_databaseDebugMode = TRUE;

...view the page again, and let me know the MySQL error message displayed that time which should give more information...

Thanks,
David.
--
PriceTapestry.com

Submitted by philstone on Tue, 2012-12-18 12:42

Perfect David!

Thanks

Have a Great Christmas!!

Phil Stone
www.buy24-7.net

Submitted by support on Tue, 2012-12-18 12:45

No worries, Phil!

I assume all fixed from the MySQL error displayed...

Have a great Christmas yourself!

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Tue, 2012-12-18 12:48

Yes, working perfectly!!! Thanks!!

regards

Phil Stone
www.buy24-7.net

Submitted by philstone on Thu, 2013-02-07 12:14

Hi David

This has been working a great for me, however sometimes the merchants have different ean numbers, for the same product, in this event i was wondering what i would add to display how many entries are using each ean, as this will in 99% of occasions help me know hwich ean to use?

eg: it would display

0183920282921 (3)
183920282921 (1)

Regards

Phil Stone
www.buy24-7.net

Submitted by support on Thu, 2013-02-07 12:21

Hi Phil,

Have a go with this as an alternative to the replacement described above:

  print "</select>";
  if ($resultCount)
  {
    $ins = array();
    foreach($rows as $row)
    {
      $ins[] = "'".database_safe($row["name"])."'";
    }
    $in = implode(",",$ins);
    $sql = "SELECT ean,COUNT(id) as numEans FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$in.") GROUP BY ean";
    if (database_querySelect($sql,$rows))
    {
      print "<h3>Associated EANs</h3>";
      print "<ul>";
      foreach($rows as $row)
      {
        print "<li>".$row["ean"]." (".$row["numEans"].")</li>";
      }
      print "</ul>";
    }
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Thu, 2013-02-07 12:41

Thanks David

Works as I had envisioned it to work

Thanks yet again!
Phil Stone
www.buy24-7.net

Submitted by philstone on Wed, 2013-12-11 23:43

Hi David

I was wondering is it possible in productmap_helper.php to add the following:

so I already use:

Associated EANs

EAN 1
EAN 2 etc...

Underneath that is it possible to add two lists:

Alternative Product Models (using $original_model)

Model 1
Model 2 etc...

Alternative Product Categories (using $category)

Category 1
Category 2 etc...

I'm just trying to make the product mapping process more efficent, instead of jumpimg between front and back ends of the site

Thanks

Phil Stone
www.buy24-7.net

Submitted by support on Thu, 2013-12-12 14:03

Hi Phil,

I don't think I have a copy of the modified admin/productsmap_helper.php that shows EAN by list, however it's straight forward to include `original_model` AND `category` in the search by looking for the following code at line 58:

  $wheres[] = "name LIKE '%".database_safe($word)."%'";

...and REPLACE with:

  $wheres[] = "CONCAT(name,original_model,category) LIKE '%".database_safe($word)."%'";

(that will mean that the search can't use an index but one could be added if necessary)

Let me know if you want the results segregated out further at all if required...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com