You are here:  » Delete solitary products


Delete solitary products

Submitted by Sven on Fri, 2017-04-21 19:15 in

Hi David,
after import I have a lot of products in the db that can't be matched with a product from an other merchant. It's the same product but the name is different from merchant to merchant and no EAN or gtin is supplied in a feed.

How would I delete automatically all products from the db that have no two prices to compare?
A price comparision without differnet prices to compare isn't looking too good :-)

Best
Sven

Submitted by support on Sat, 2017-04-22 08:36

Hello Sven,

The following script will do the trick; save as scripts/purge.php, and you could chain it with your cron process to follow uidmap.php in the same way - let me know if you're not sure of course;

<?php
  set_time_limit
(0);
  require(
"../includes/common.php");
  
$sql "SELECT id,COUNT(id) AS numMerchants,name FROM `".$config_databaseTablePrefix."products` GROUP BY name HAVING numMerchants = 1";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $row)
    {
      
$sql "DELETE FROM `".$config_databaseTablePrefix."products` WHERE id='".$row["id"]."'";
      
database_queryModify($sql,$result);
    }
  }
  print 
"Done.";
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by Sven on Wed, 2017-04-26 21:20

Thanx! Works perfectly!