You are here:  » negative keywords


negative keywords

Submitted by fluff on Tue, 2013-01-15 10:21 in

Is there a way to implement negative keywords in the WP plugin?

I know that in PT you can edit some files but can you do the same for PTO?

Cheers

Submitted by support on Tue, 2013-01-15 11:44

Hi,

The IN BOOLEAN MODE mod can be added to pto_search.php for negative keyword support. To do this, look for the following code beginning at line 256:

  $where = "MATCH ".$matchFields." AGAINST ('".$wpdb->escape($parts[0])."')";
  $sql = "SELECT SQL_CALC_FOUND_ROWS * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH ".$matchFields." AGAINST ('".$wpdb->escape($parts[0])."') AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY name";

...and REPLACE with:

  $where = "MATCH ".$matchFields." AGAINST ('".$wpdb->escape($parts[0])."' IN BOOLEAN MODE)";
  $sql = "SELECT SQL_CALC_FOUND_ROWS * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH ".$matchFields." AGAINST ('".$wpdb->escape($parts[0])."' IN BOOLEAN MODE) AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY name";

You'll then be able to search for example

this +that -notthis

So in the above query, "this" - optional (no prefix), "that" - must include ("+" prefix) and "notthis" - must not include ("-" prefix)

Cheers,
David.
--
PriceTapestry.com

Submitted by fluff on Tue, 2013-01-15 12:33

brillant thanks works like a charm

it was driving me nuts to have a totally unrelated item returned just because they used a word in the title!!