You are here:  » Mapped products

Support Forum



Mapped products

Submitted by JasonG on Tue, 2012-04-03 09:09 in

Hi David

I can see products that I have mapped manually by going to {link saved}

I am pretty confident that there are other products that have been mapped naturallly, as the names woudl be the same. Please correct me if I am wrong!

Is there anyway I can get All "manually" and "naturally" mapped products to show in this area: {link saved}

Regards
Stuart

Submitted by support on Tue, 2012-04-03 10:58

Hi Stuart,

The SQL to fetch naturally compared products, excluding those with an existing Product Mapping set-up would be:

select name,COUNT(id) AS numMerchants FROM `pt_products` WHERE name NOT IN (SELECT name FROM pt_productsmap) GROUP BY name HAVING numMerchants > 1;

So yes - this could be integrated into admin/productsmap.php with a configure link to create and then edit custom fields etc.. First, look for the following code at line 84:

  print "<h3>New Product</h3>";

...and REPLACE with:

  $sql = "SELECT name,COUNT(id) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name NOT IN (SELECT name FROM ".$config_databaseTablePrefix."productsmap) GROUP BY name HAVING numMerchants > 1";
  if (database_querySelect($sql,$products))
  {
    print "<h3>Naturally Mapped Products</h3>";
    print "<table>";
    foreach($products as $product)
    {
      print "<tr>";
      print "<th align='left'>".$product["name"]."</th>";
      print "<td>&nbsp;&nbsp;";
      print "<a href='productsmap.php?name=".urlencode($product["name"])."'>Configure</a>";
      print "</td>";
      print "</tr>";
    }
    print "</table>";
  }
  print "<h3>New Product</h3>";

And then look for the following code at line 10:

  if (isset($_POST["submit"]) && isset($_POST["name"]))

...and REPLACE with:

  if (isset($_GET["name"]))
  {
    $_POST["name"] = $_GET["name"];
    $_POST["submit"] = TRUE;
  }
  if (isset($_POST["submit"]) && isset($_POST["name"]))

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by JasonG on Tue, 2012-04-03 11:47

Thanks David

Have done the above but getting this at the bottom of the mapped products

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in {code saved} on line 27

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in {code saved} on line 32

Regards
Stuart

Submitted by support on Tue, 2012-04-03 12:24

Sorry Jason some extra "_" characters had crept into the SQL, which should be:

  $sql = "SELECT name,COUNT(id) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name NOT IN (SELECT name FROM ".$config_databaseTablePrefix."productsmap) GROUP BY name HAVING numMerchants > 1";

corrected above also...

Cheers,
David.
--
PriceTapestry.com

Submitted by JasonG on Tue, 2012-04-03 12:56

Thanks, that has cleared the errors. I now see "Naturally Mapped Products" but there is 211 of the same product and nothing else. Could that be an error?

I did not make a note of a product I found that was being mapped naturally, but I am convinced that with over 24,000 products in varioius feeds, there would be more than 1 product being naturally mapped. I could be wrong of course!

Any ideas

I can email a screen shot if it helps

regards
Stuart

Submitted by support on Tue, 2012-04-03 13:22

Hi Stuart,

Corrected above;

This line

print "<th align='left'>".$productsmap["name"]."</th>";

should be:

print "<th align='left'>".$product["name"]."</th>";

Cheers,
David.
--
PriceTapestry.com

Submitted by JasonG on Tue, 2012-04-03 13:27

Great, looks ok now, will let you know if I find anything wrong or need more help

Cheers
Stuart