You are here:  » Is it possible to show a merchant and what items they uniquely?

Support Forum



Is it possible to show a merchant and what items they uniquely?

Submitted by mally on Tue, 2008-12-30 21:44 in

Hello David

I've got a merchant who has a really bad conversion rate but I only want to remove the products that another merchant actually sells.

Would it be possible to have a script where I could enter the merchants name and to get a screen showing the products sold by others.

I could then add manually a filter removing those product names..

Thanks

Mally

Submitted by support on Wed, 2008-12-31 09:33

Hi Mally,

Try something like this:

<?php
  header
("Content-Type: text/plain");
  require(
"includes/common.php");
  
$merchant "Bad Merchant Name";
  
$sql "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY name";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      
$sql "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' AND merchant <> '".database_safe($merchant)."' LIMIT 1";
      if (
database_querySelect($sql,$rows2))
      {
        print 
$product["name"]."\n";
      }
    }
  }
?>

Cheers,
David.

Submitted by mally on Wed, 2008-12-31 10:45

Hello David

Thanks that works!

Is there a away I can add this to drop record so I can add all the names there?

(HD|High Def)

Just like the Drop Record If Not RegExp filter, this would save me loads of time

Thanks

Mally

Submitted by support on Wed, 2008-12-31 11:19

Hi Mally,

You could add "Drop Record RegExp" if you like (to includes/filter.php):

  /*************************************************/
  /* dropRecordRegExp */
  /*************************************************/
  $filter_names["dropRecordRegExp"] = "Drop Record RegExp";
  function filter_dropRecordRegExpConfigure($filter_data)
  {
    print "Drop record if field matches regular expression:<br />";
    print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    widget_errorGet("text");
  }
  function filter_dropRecordRegExpValidate($filter_data)
  {
  }
  function filter_dropRecordRegExpExec($filter_data,$text)
  {
    global $filter_dropRecordFlag;
    if($filter_dropRecordFlag)
    {
      return $text;
    }
    else
    {
      $filter_dropRecordFlag = ereg($filter_data["text"],$text);
    }
    return $text;
  }

However, if there are many products this might be somewhat inefficient. It would only take a couple more lines of code to the above script to actually delete the products from the bad merchant, i.e.:

<?php
  header
("Content-Type: text/plain");
  require(
"includes/common.php");
  
$merchant "Bad Merchant Name";
  
$sql "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY name";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      
$sql "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' AND merchant <> '".database_safe($merchant)."' LIMIT 1";
      if (
database_querySelect($sql,$rows2))
      {
        print 
$product["name"]."\n";
        
$sql "DELETE FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' AND merchant = '".database_safe($merchant)."'";
        
database_queryModify($sql,$result);
      }
    }
  }
?>

Cheers,
David.

Submitted by mally on Thu, 2009-07-16 16:22

Hi David

I've tried using the drop drop filter above, using (example|example|example|example|example|example|example|example|example| and so on however it's not removing them all, only some.. Can you check the filter code please? Thanks Malcolm

Submitted by support on Thu, 2009-07-16 16:31

Hi Mally,

The filters are applied after normalisation etc. so would need to be the exact values as imported rather than the original values in the feed.

If that doesn't help, could you perhaps email me the details of your exact filter configuration, and the name of a feed that it is not being applied correctly to correctly, and i'll download it to my test server and check it out...

Cheers,
David.