You are here:  » Search


Search

Submitted by gunawin on Fri, 2015-04-03 19:20 in

Hello David,

Is the search function in your script only based on "Product Name"? I have tried to search by Merchant or Category but return with no result.

Is it possible to implement the search function on both (by Merchant or Category) or maybe search by any string that match?

Please advise

Thanks in advance,
Gunawin

Submitted by support on Sat, 2015-04-04 07:22

Hello Gunawin,

Basic keyword search is optimised by product, by way of the indexes created against the product name field.

There are two methods used - the FULLTEXT index, invoked when all keywords in the query are > 3 characters, or the basic method, which uses a simple LIKE select clause.

The FULLTEXT method can be disabled easily, and the basic method expanded to include any additional fields you would like to include in the search. To do this, first disable the use of the FULLTEXT index by editing line 8 of config.advnaced.php as follows:

  $config_useFullText = FALSE;

Then, in search.php look for the following code at line 305:

  $where .= "search_name LIKE '%".database_safe($word)."%'";

...and to include merchant and category, REPLACE with:

  $where .= "search_name LIKE '%".database_safe($word)."%'";
  $where .= " OR merchant LIKE '%".database_safe($word)."%'";
  $where .= " OR category LIKE '%".database_safe($word)."%'";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by gunawin on Mon, 2015-04-06 12:03

Hi David,

It works great, however, it seems does not work with spaces
Can you please help

Cheers,
Gunawin

Submitted by support on Mon, 2015-04-06 15:23

Hello Gunawin,

The above method creates separate sub-WHERE clauses for each word, so although all results should be present it might work better with separate WHERE clauses for an exact match against merchant and category. To try this, if you revert the above modification to search.php and instead look for the following code at line 329:

  $where = implode(" AND ",$wheres);

...and REPLACE with:

  $where = implode(" AND ",$wheres);
  $where = "(".$where.") OR (merchant='".database_safe($q)."') OR (category='".database_safe($q)."')";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com