Jump to content

Fix for reference search in combinations


Recommended Posts

  • 2 weeks later...

i sorted out my issue... the problem was that as per one forum post i needed to order my attributes and attribute groups... so i had 001. 002. 003. in all my attributes... now when prestashop was indexing for the search, it was indexing 001.Atribute name instead of only the "attribute name". I had to sit and add a space to all my attributes and regenerate the index and it works fine now...

kindly note, this problem occured because if prestashop has indexed "001.attribute name" and one searches for "attribute" it doesnt seem to be picking up parts of words... so only a search for "name" or "001.attribute" would lead to a match.

hope this helps...

Link to comment
Share on other sites

  Quote
i sorted out my issue... the problem was that as per one forum post i needed to order my attributes and attribute groups... so i had 001. 002. 003. in all my attributes... now when prestashop was indexing for the search, it was indexing 001.Atribute name instead of only the "attribute name". I had to sit and add a space to all my attributes and regenerate the index and it works fine now...

kindly note, this problem occured because if prestashop has indexed "001.attribute name" and one searches for "attribute" it doesnt seem to be picking up parts of words... so only a search for "name" or "001.attribute" would lead to a match.

hope this helps...


Prestashop searches based on minimum word length. If you set it to 2 than it search for first 2 characters in words from search_words table.If you want to search inside words you have to change in find function from search class adding a % character in select query where appears like operator.
Link to comment
Share on other sites

  Quote
could ylou please help me add a find function to search the reference tables


The find function is in Search class (classes/Search.php). It searches the words indexed by prestashop (which includes the references for products but only those without combinations of attributes).
Try rebuilt the entire index in back ofice.
Link to comment
Share on other sites

  • 3 years later...

For searching inside of word you need to add % character in SELECT SQL function, somewhere on line 190.

 

See the difference from this code (original)

 

$intersectArray[] = 'SELECT id_product
 FROM '._DB_PREFIX_.'search_word sw
 LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
 WHERE sw.id_lang = '.(int)$id_lang.'
 AND sw.word LIKE
 '.($word[0] == '-'
  ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
  : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
 );

 

And this is edited code that allows you to search inside of indexed word not only for first characters

 

$intersectArray[] = 'SELECT id_product
 FROM '._DB_PREFIX_.'search_word sw
 LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
 WHERE sw.id_lang = '.(int)$id_lang.'
 AND sw.word LIKE
 '.($word[0] == '-'
  ? ' \'%'.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
  : '\'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
 );

 

This helped me

 

  Quote
You can just use wildcards in the predicate (after IF, WHERE or ON):

@mainstring LIKE '%' + @substring + '%'

or in this specific case

' ' + @mainstring + ' ' LIKE '% ME[., ]%'

(Put the spaces in the quoted string if you're looking for the whole word, or leave them out if ME can be part of a bigger word).

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...