You are here:  » Show Product Mapping with no matches


Show Product Mapping with no matches

Submitted by philstone on Mon, 2013-12-16 16:22 in

Hi David

Hope you had a nice weekend

I was wondering would there be a script available for /admin/ that would show a page of all product mappings with '0' matches, to make it easy to delete them, I had a script you shared with me previously that showed a count beside each map, but now with using uidmap I have over 11,000 product mappings on just one installation and I think something like this would possibly load quicker.

or

Do you think it may be better instead of showing the redirect loop page could it divert to the noresults.php page? this would also allow the mapping to reappear should another merchant start selling the same product?

Your advice and/or help on this would be greatly appreciated

Regards

Phil
Buy24-7.net

Submitted by support on Tue, 2013-12-17 16:34

Hi Phil,

Would a script to purge `pt_productsmap` of any entries not being applied to live products in the database? That would be straight, but because of the size of your auto-generated mapping table would need to be done using buffered queries, but the following code would do the trick:

<?php
  set_time_limit
();
  require(
"includes/common.php");
  
header("Content-Type: text/plain");
  
$link1 = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword,TRUE);
  
mysql_select_db($config_databaseName,$link1);
  
$link2 = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword,TRUE);
  
mysql_select_db($config_databaseName,$link2);
  
$sql1 "SELECT name,id FROM `".$config_databaseTablePrefix."productsmap`";
  
$result1 mysql_unbuffered_query($sql1,$link1);
  while(
$row mysql_fetch_array($result1,MYSQL_ASSOC))
  {
    
$sql2 "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($row["name"])."'";
    
$result2 mysql_query($sql2,$link2);
    if (!
mysql_num_rows($result2))
    {
      print 
"DELETING: ".$row["name"]."\n";
      
$sql2 "DELETE FROM `".$config_databaseTablePrefix."productsmap` WHERE id='".database_safe($row["id"])."'";
      
$result2 mysql_query($sql2,$link2);
    }
  }
?>

Run from Price Tapestry top level installation folder, or to set-up to run from /scripts/ or /admin/ simply REPLACE

  require("includes/common.php");

with:

  require("../includes/common.php");

As always, make sure well backed up first!!

Cheers,
David.
--
PriceTapestry.com

Submitted by philstone on Tue, 2013-12-17 22:28

Hi David

This worked perfect on all installations, Thank-you!

regards

Phil Stone
www.buy24-7.net