Jump to content

Search for the Front and Back Office are two different Animals Why? Front Office does not Work Correctly = Lost Sales!


Recommended Posts

Well after testing this on prestashop 1.2.5 all the way to 1.4.2.5 it still hosed. The front office search is totally different code. Why is that? The back office search works flawlessly! The front office search is broken bad and is responsible for lost sales daily.



Bug Report
-----
Hey Billy, check out the search on the store and see if something has gotten out of wack. For example, search for a 74LS377 and see what you come up with. If you type in the whole prefix it comes up just fine. If you only type LS377 nothing will show. However, in the store admin the search works great. Check it out and see what you think. I bet its a setting that needs to be tweaked.
-----

Link to comment
Share on other sites

  • 1 year later...

My solution is replacing code of FO search by BO search.

 

FO search uses search_word and search_index tables but BO search uses SQL query directly.

 

Find these code in /classes/search.php:

 

 

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]);

 

replace by:

 

 

$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.name LIKE \'%'.pSQL($expr).'%\'';

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 3 weeks later...
  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...