You are here:  » Disable specific filter


Disable specific filter

Submitted by stevebi on Sun, 2015-12-13 01:25 in

Hello David,

May I ask if it is possible to disable a specific filter of a merchant or the only way is to de register this filter from the merchant feed

Cheers

Steve

Submitted by support on Sun, 2015-12-13 10:54

Hi Steve,

It's straight forward to add a `disabled` flag to the filters table so that you can temporarily prevent a filter from taking effect. First, run the following dbmod.php script from top level folder of the Price Tapestry installation to create the flag:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."filters`
            ADD `disabled` INT(11) NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Next, edit admin/feeds_filters_configure.php and look for the following code at line 59:

    unset($_POST["submit"]);

...and REPLACE with:

    unset($_POST["submit"]);
    $disabled = (isset($_POST["disabled"])?"1":"0");
    unset($_POST["disabled"]);

And then the following code at line 75:

      $sql = "UPDATE `".$config_databaseTablePrefix."filters` SET data = '".database_safe(serialize($filter["data"]))."' WHERE id='".database_safe($id)."'";

...and REPLACE with:

      $sql = "UPDATE `".$config_databaseTablePrefix."filters` SET disabled='".database_safe($disabled)."', data = '".database_safe(serialize($filter["data"]))."' WHERE id='".database_safe($id)."'";

And then the following code at line 115:

  $configureFunction($filter["data"]);

...and REPLACE with:

  $configureFunction($filter["data"]);
  widget_checkBox("Disabled?","disabled",FALSE,$filter["disabled"]);

Finally, in includes/admin.php, look for the filter selection SQL around line 665:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."filters` WHERE filename='".database_safe($admin_importFeed["filename"])."' OR filename='' ORDER BY filename,created";

...and REPLACE with:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."filters` WHERE (filename='".database_safe($admin_importFeed["filename"])."' OR filename='') AND disabled='0' ORDER BY filename,created";

With the above in place, a "Disabled?" checkbox will be displayed on the configuration page for a filter, immediately above the Save button. Check and then Save to disable a filter. To indicate disabled filters with strickethru, edit admin/feeds_filters.php and look for the following code at line 133:

      print "<th class='pta_key'>".$filter_names[$filter["name"]]."</th>";

...and REPLACE with:

      print "<th class='pta_key'>".($filter["disabled"]?"<s>":"").$filter_names[$filter["name"]].($filter["disabled"]?"</s>":"")."</th>";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com