Shineslo Posted May 27, 2013 Share Posted May 27, 2013 I have a PS 1.4.3 running a custom template. I almost went out of my mind, because I wasn't able to make ****** search function to work properly. Because I do not know a lot about programing I learn through this forum and try to implement new solutions in my shop. No matter what I did, search function wasn't working properly. With some searching on this forum I found a brilliant solution and I would like to share it with you if you will find it useful: 1. open /classes/search.php Delete or /* */ lines from 170-188 foreach ($words AS $key => $word) if (!empty($word) AND strlen($word) >= (int)Configuration::get('PS_SEARCH_MINWORDLEN')) { $word = str_replace('%', '\\%', $word); $word = str_replace('_', '\\_', $word); $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)).'%\'' ); if ($word[0] != '-') $scoreArray[] = 'sw.word LIKE \''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; } else unset($words[$key]); and change it with this: $intersectArray[] = 'SELECT distinct p.id_product FROM ps_product p LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$id_lang.') WHERE pl.description LIKE \'%'.pSQL($expr).'%\''; look at the last line... WHERE pl.description pl. description is a table in sql database if you have this in the code you will be able to search by words in product description, you can also make it to search by description_short or meta_description, etc... I hope this solution will be as useful for you as it is for me Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now