Jump to content

search additional fields


Recommended Posts

Ooops! I lost track of this project.

Several versions back, I created a Code Snippet that adds the fields to the searchable collection of fields. I need to double check that it still works for CC625.

If you want to verify if, in the snippet's current version, works for you, send me a Private Message with your email address.

Link to post
Share on other sites

In /classes/catalogue.class.php, the public function searchCatalogue(), has the code to take the search terms, incorporate other search criteria, builds the JOINs of other tables, if necessary, and builds the WHERE clause, and sends the query to the database.

This function is attempted up to three times, each using a different database search mechanism: FULLTEXT (will not work with other than fulltext indexes), then if nothing found uses RLIKE (regular expressions), then if nothing found uses a more lenient LIKE (simple wildcards).

 

Edited by bsmither
Link to post
Share on other sites
  • 2 months later...

Hi all, I found the code which says :

$like = " AND (I.name ".$like_keyword." '".$regexp."' OR I.description ".$like_keyword." '".$regexp_desc."' OR I.product_code ".$like_keyword." '".$regexp."')";

However, when I change 'description' to another data base column it starts searching in that new column indeed but still keeps searching the 'description' one too. Would anyone know why ?

Link to post
Share on other sites

CubeCart makes searches using up to three methods.

The first method uses what is called "FULLTEXT" search on an index that is created against the columns 'product_code', 'description', and 'name'.

If nothing is found, then the second method uses regex expressions on the named columns.

If that returns nothing, the third method uses simple wildcards on the named columns.

So, if your search results are including words in the description, then perhaps the search process is finding those results using the first of the search methods. The second and third methods use the SQL query - the $like string - which you posted earlier.

Link to post
Share on other sites

I actually got it. You can amend the code at /classes/catalogue.class.php, the public function searchCatalogue().

you can add the column you want the search engine to look at below :

$like = " AND (I.name ".$like_keyword." '".$regexp."' OR I.description ".$like_keyword." '".$regexp_desc."' OR I.product_code ".$like_keyword." '".$regexp."')";

However, if you want to avoid the search engine from looking into the description column you need to DROP it from the indexes in your MySQL database in the FULLTEXT keyname. You can therefore add other columns instead there and make it search where you want it. tricky....

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...