Jump to content

Shop search v2.1.0(statssearch) not write searched words in ps_statssearch table


elly63

Recommended Posts

Hi everyone,
I updated to PS 8.2;
the Shop Search 2.1.0 module, however, doesn't write the search terms to its table (ps_statssearch).
I've already tried uninstalling and reinstalling the module;
everything is fine, and the table is correctly created in the database;
however, the problem persists; it isn't populated when searching from the website's front end.
The back office also correctly reports in the statistics that no search terms were found, since the table is empty. For testing, I manually inserted a row into the ps_statssearch table, and the back office displays the entered data.
Any suggestions?

Link to comment
Share on other sites

This is a known issue after upgrading to PS 8.x — the search terms are often not logged because the hook that the statssearch module depends on is no longer fired, or the search controller is bypassing it.

Below are the main things to check.

1. Check that the module is hooked to actionSearch (critical)

The statssearch (Shop Search) module relies on this hook to write terms into ps_statssearch.

After the upgrade, it’s common for modules to lose hook assignments.

Ask the member to check:

Back office → Modules → Module Manager → Shop Search → Configure → “Exceptions & Hooks”

Make sure the module is attached to:

  • actionSearch
  • displayHeader (not required for logging, but sometimes needed)

If actionSearch is missing, add it manually.

Note; there are other reasons but this is the primary thing to look at first.

Link to comment
Share on other sites

First,
thanks for the quick response.
Second,
I checked the SHOP SEARCH 2.1 module's hooks as you wrote, and
- the module is correctly connected to actionSearch.
- it cannot be connected to displayHeader, which doesn't appear in the list of available hooks (img 2).

Any other ideas?

2025-11-29_071055.jpg

hooked.PNG

Link to comment
Share on other sites

Hello,

displayHead is not needed. The statssearch module makes use only of the actionSearch and displayAdminStatsModule hooks

Some things that you should watch for:

1. Check the `ps_hook` table and make sure that active is set to 1 for actionSearch. You can also add position 1 (to the same row) if it's not already set (SELECT * FROM `ps_hook` WHERE name = 'actionSearch';)

2. Make sure there are no overrides (or direct code changes) for controllers/front/listing/SearchController.php, src/Adapter/Search/SearchProductSearchProvider.php and modules/statssearch/statssearch.php. If there are, you should check the code for them in GitHub and make sure you are not touching the execution of the actionSearch hook

  • Like 1
Link to comment
Share on other sites

Hi Andrei,

To be safe, I downloaded 8.2 from GITHUB and replaced the folders
controllers/front/listing/
src/Adapter/Search/
modules/statssearch/ directly on the server.
I cleared the cache.
I ran a search from the front.
But nothing, no writing to the ps_statssearch table.
I'm attaching a screenshot of the BO where it seems that online users used to appear in addition to the 'active shopping carts'... maybe the problems are related.

thanks

Link to comment
Share on other sites

Hello,

Do you have any custom search modules installed? Or any module that implements the 'productSearchProvider' hook?

Can you try the following: go to classes/controller/ProductListingFrontController.php and on line 317, add the following code:

die(get_class($provider));

Then try and search something. When redirected to the search page, what are you seeing? Is it PrestaShop\PrestaShop\Adapter\Search\SearchProductSearchProvider?

Link to comment
Share on other sites

Hello,

Ok, this makes more sense now.

In your ps_facetedsearch module's configuration, in the template used, you are most likely having Search (experimental) checked in the Pages using this template: section.

The problem seems to be the fact that ps_facetedsearch does not execute the actionSearch hook. If you uncheck that option, the default search class will be used in the search page, and this class does implement the hook, so you should start seeing the search keywords inserted into that table.

Edited by Andrei H (see edit history)
  • Thanks 2
Link to comment
Share on other sites

Hello,

Since this is experimental, you would expect things to be missing.

You can manually fix it for now. You can edit modules/ps_facetedsearch/src/Product/SearchProvider.php and on line 197 add the following:

\Hook::exec('actionSearch', [
    'searched_query' => $query->getSearchString(),
    'total' => $productsAndCount['count'],
    'expr' => $query->getSearchString(),
]);

If it's inserting things twice, this means the hook is called twice, although it shouldn't. Did you add it for debugging somewhere in the code and forgot to remove it?

  • Thanks 1
Link to comment
Share on other sites

a, I understand, it writes lines every time you add text and give it time to preview the results... I type cia, it previews the results under the search bar, then I add "o" and it previews the results again, and it writes both the line with "cia" and "ciao."
I don't know if I'm understandable, my English is googleenglish.

 

Tomorrow I'll test with the code you told me and I'll let you know... now I'm exhausted...

Link to comment
Share on other sites

11 hours ago, Andrei H said:

Hello,

Since this is experimental, you would expect things to be missing.

You can manually fix it for now. You can edit modules/ps_facetedsearch/src/Product/SearchProvider.php and on line 197 add the following:

\Hook::exec('actionSearch', [
    'searched_query' => $query->getSearchString(),
    'total' => $productsAndCount['count'],
    'expr' => $query->getSearchString(),
]);

If it's inserting things twice, this means the hook is called twice, although it shouldn't. Did you add it for debugging somewhere in the code and forgot to remove it?

ok, it works👍...

Thanks again for the help

  • Like 2
Link to comment
Share on other sites

Hi,

We've solved the writing problem in the ps_statssearch table, but I have a few considerations:

- Between yesterday and today (24 hours), the table was populated with 5,000 rows.

- Of these 5,000, after running

DELETE FROM yourTableName WHERE yourColumnName IS NULL OR yourColumnName = '';

There are about 80 left.

Now I'm trying to

-modify statssearch.php with some if statements.

-or insert a 'before triggers' statement in mysql so that it doesn't write rows with the keywords ""

Link to comment
Share on other sites

Hi,
Anyway, the code that writes ps_statssearch to the DB needs to be made smarter.
Yesterday I did a search on the site I manage, and when I searched for "testando" in the DB, 8 lines were written in 8 seconds... and thank goodness I included the strlen if on the var ...
I'm trying to implement some SQL triggers that will improve the situation...
Maybe someone more knowledgeable on GITHUB will be able to make the module smarter...

Ciao 😉

image.thumb.png.2da057453fe9b6eaf9e8077501776059.png

Link to comment
Share on other sites

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...