Jump to content

How can search by product id??


Recommended Posts

ha,i get it.

classes/search.php

replace

$whereArray[] = ' p.id_product '.($word[0] == '-' ? 'NOT' : '').' IN (
                   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 = '.intval($id_lang).'
                   AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').'
               ) ';
               if ($word[0] != '-')
                   $scoreArray[] = 'sw.word LIKE \''.pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'';




to

if(intval($word)) {
                   $whereArray[] = ' p.id_product = '.intval($word);
               }else{

                   $whereArray[] = ' p.id_product '.($word[0] == '-' ? 'NOT' : '').' IN (
                   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 = '.intval($id_lang).'
                   AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').'
               ) ';
               if ($word[0] != '-')
                   $scoreArray[] = 'sw.word LIKE \''.pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'';

               }

Link to comment
Share on other sites

  • 2 weeks later...

Hi Guys,

I would like to populate my Search_word and search_index on "Category description" rather than "Category name"?

I can see the indexation function in the classes\search.php and have changed

 SELECT p.id_product, pl.id_lang, pl.name as pname, p.reference, p.ean13, pl.description_short, pl.description, cl.name as cname, m.name as mname



To

 SELECT p.id_product, pl.id_lang, pl.name as pname, p.reference, p.ean13, pl.description_short, pl.description, cl.description as cname, m.name as mname



is there anything else I need to do as this appears to work?

Link to comment
Share on other sites

×
×
  • Create New...