Jump to content
Sign in to follow this  
neti_treves

search additional fields

Recommended Posts

Hi all,

I've created some more db fields for my products.

How can I have the search query go through these new fields as well?

Thanks

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Well, it's not what I thought it was.

But I will keep working on a solution.

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

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 ?

Share this post


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.

Share this post


Link to post
Share on other sites

I have been trying to understand how to avoid the keywords searching into the description columns but all to no avail. I guess this is too complex in the whole catalogue.class.php scripting to amend. I have made made changes but this is now beyond me... Thank you in any case.

Share this post


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....

 

Share this post


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.

Sign in to follow this  

×
×
  • Create New...