Jump to content

A big Problem of Search issues in Front office


Recommended Posts

Hello,
Today I find a big problem with searching function in Front office, i read all the topics i can find in the forum, but no lucky.
I try to search by: tag, reference number, entire title name, non working!!!
some friend suggest me to rebuild the entier index, but that is worse!! i can not search any results which is can be found before.
At same time, back office search function is better, it is able to find out all the items at back office by input any keywords.

Anyone could help? or How can i move the back office search function to front office?
Thanks!

Link to comment
Share on other sites

  • 2 months later...

I just upgraded to 1.4.2.5. I am now having searching issues similar to above mentioned. In the BO, if I do a search, it will find the products just fine, but doing the same keyword product search in the FO returns zilch results.

I have tried re-indexing as well as nuking my products and re-importing, force compiling, different minimum word length, allowing and not-allowing friendly URLs. etc...

Please, please, please any ideas, suggestions, help would be seriously appreciated!

Thank you in advance for anyone's time and efforts!

JTLS

Link to comment
Share on other sites

Hey Angora,

Well, I think I should of mentioned that I have over 15,000 products :-)

The searchfix.php file works but times-out on my end probably because I have so many products. Some of products are starting to show up in the search section now that were not available before. Can I change the max_execution_time to a higher number? or is there another way you might know?

Thanks for your wisdom!

JTLS

Link to comment
Share on other sites

Try this. Copy/paste the following into a file and place it on your server in the path
admin/searchfix.php
then visit its URL in your browser ( http://myshop/myadminpath/searchfix.php )
.
Afterward, (remove the utility script and) check whether the front office search now behaves properly
<?php
@ini_set('display_errors', 'on');
require_once(dirname(__FILE__).'/../config/config.inc.php');
require_once(dirname(__FILE__).'/init.php');  

ini_set('max_execution_time', 7200);
Search::indexation('true');
echo 'success -- search index has been rebuilt';  
?>



If the problem persists, toward troubleshooting I would have some questions:

What was your ps version prior to the upgrade?

"front office keyword product search" means using tag(s) as the search query?
If so, have you browsed the "tag" table using phpmyadmin to verify whether or not the table is empty (0 rows) ?




I'm having a problem with the search index as well. It won't index the products. I've tried both the "Add missing products to index" and "Re-build entire index" and it doesn't change. It just keeps showing "Indexed products: 0 / 9011".

I have also created the file above and ran it on my server and it said "success -- search index has been rebuilt" but still it shows 0 products indexed.

Any more ideas?

Is there a way to run a check on the database to make sure the data is not corrupted or if there might be an invalid character or something that could be causing the problem. I'm starting to think it might be something within the data on the database because I can't backup the database using the internal prestashop backup either. When I try and do a DB backup I get "An error occur while backing up. Unable to obtain the schema of "ps_product_sale"
Link to comment
Share on other sites

  • 1 month later...

I have the exact same problem as you guys with v1.4.3. I had the problem with 1.3.7 as well.

We have over 20.000 products in our store and we are going to depend on people being able to search, so any inputs are welcome.

 

Hope we can fix this together.

Link to comment
Share on other sites

Here is what i have tried:

 

- reindexing the search.

- removing all files from the tables: ps_search_index and ps_search_word and reindexing again.

- indexing a few products and then try to search, same result.

 

So frustrating :-/

Link to comment
Share on other sites

  • 2 weeks later...

I have almost same problem - indexing cron job does not add all words from product description.

 

I've imported product description with htm tables inside with phpmyadmin, rebuilded index and only part of description went into ps_search_words table. Reindex does not help. The only help the following:

1) edit product in back office: just add space or enter and save (it's terrible to wait - after save PS removes product from search index and add it again) - takes long time

or

2) get descriptin field to notepad, manualy edit it (mainly changing layout - spaces, enter, tabs) and paste it back to ps_product_land and set index in ps_product table = 0 and then "add missing products" to index

 

Then all needed words appear in ps_search_words and after it I can serch all words what are in description field.

 

I expect, that indexing routine does not accept correctly data from field description from ps_product_lang if there is html code (in my case it was table).

 

A bit confused, how I can fix those 13.000 products that all their description will be indexed :(

 

Forgot to mention: I use 1.4.3 version

Link to comment
Share on other sites

I have the similar problem but try the following steps to get back the search functions.

 

You might want to try out the following steps:

 

1. Disable the Friendly URL from Preferences SEO & URLs -> URsL Setup

2. Regenerate the .htaccess file without enable the Friendly URL from Tools -> Generator

3. Rebuild the full index from Preferences -> Search.

 

The only drawback is your website don't have the Friendly URL.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 4 weeks later...
  • 7 months 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:

 

 

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).'%\'';

 

My website: www.sachdinhle.com

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Solution: upgrade to latest Prestashop (a lot has been improved!), or, if you cannot upgrade, update only indexation functions

 

Search in my Prestashop 1.4.2.5. broke down recently (slow, inclomplete, problems with accented characters). I was searching for a solution, noticed that ps_search_index has incomplete results etc.

 

Next, I noticed a lot has been improved in latest version of Prestahop regarding search (see changelogs). In my case, I couldn't upgrade (my shop is heavily customised), the solution for me was to update indexation functions only, it works great since – what you have to do is to download the latest Prestashop and replace current and add a couple of new functions:

 

Classes/Search.php

replace public static function indexation

add protected static function getProductsToIndex

 

Classes/Tools.php

add public static function replaceAccentedChars

Link to comment
Share on other sites

  • 5 months 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:

 

 

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).'%\'';

 

My website: www.sachdinhle.com

 

Solved thanks to your post!

 

Thank you

Link to comment
Share on other sites

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:

 

 

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).'%\'';

 

My website: www.sachdinhle.com

 

Does not work with reference numbers. How we can fix that?

 

 

Solution: upgrade to latest Prestashop (a lot has been improved!), or, if you cannot upgrade, update only indexation functions

 

Search in my Prestashop 1.4.2.5. broke down recently (slow, inclomplete, problems with accented characters). I was searching for a solution, noticed that ps_search_index has incomplete results etc.

 

Next, I noticed a lot has been improved in latest version of Prestahop regarding search (see changelogs). In my case, I couldn't upgrade (my shop is heavily customised), the solution for me was to update indexation functions only, it works great since – what you have to do is to download the latest Prestashop and replace current and add a couple of new functions:

 

Classes/Search.php

replace public static function indexation

add protected static function getProductsToIndex

 

Classes/Tools.php

add public static function replaceAccentedChars

 

Does not work for me, or can you explain this solution more in detail? Thanks a lot.

Link to comment
Share on other sites

×
×
  • Create New...