Jump to content

Problem filters when overriding an admin module controller


Recommended Posts

Hello,

We're taking over the technical management of a site. 

The previous developers overridden the admin controller of a module (opartdevis),
The problem is that, when the override is present, the filters in the list don't work properly:
We can submit the filter, which does filter the list, but the filter fields remain empty & the "Reset" button doesn't appear.

After some investigation, I've noticed that, even if I empty the override completely, leaving just :

class AdminOpartdevisControllerOverride extends AdminOpartdevisController
{
   
}

the fields always remain empty when a search is submitted. 

However, if I delete the file, the filters work normally.

 

Do you know why this happens, and how to keep the filters working properly while keeping the override? 

Thanks in advance! :D

Link to comment
Share on other sites

Hello, how are you? It's important to know your PrestaShop version. If you're using PrestaShop 8 versions, manually clearing the cache is crucial; simply clearing it from the back office isn't sufficient. This is a lesson I've learned the hard way. After each change, make sure to clear it, as this can cause you many issues. Let me know if you have any questions. Best regards, and have a great day!

Link to comment
Share on other sites

Hello, I understand you well. It can be very frustrating. But keep in mind that when a database determines an order, sometimes products match, and if you can check the developer's FAQ, it will tell you that in such cases, the products are arranged randomly. This means that products with the same date can be arranged differently in an order. Nevertheless, I can check it if you provide the necessary credentials for your website in private. Best regards.

Link to comment
Share on other sites

Hello ! 

Thank's for your replies, 
For the first reply, we're working on a 1.7.8.8 version, and even when I delete the var/cache/{dev,prod} folders, the problem is still present :( 

For the second reply, I think it's not an answer to my topic ? I don't see what my question has to do with the answer 😕,

I don't understand why, when I override a module's AdminController, the filter no longer works correctly

Best regards

Link to comment
Share on other sites

Hello, for those who want to know, I've found the solution because I had the same problem in the past without knowing why, so:

 

just add this code:

$this->controller_name = self::class;

to the override construct after 

parent::__construct

 

Otherwise there will be 2 instances stored in the cookie, the override and the non-override, with a conflict:

[moduleclassnameoverrideorderFilter_c!lastname] => demo
[moduleclassnameorderFilter_c!lastname] => demo

 

Enjoy :)

  • Like 1
Link to comment
Share on other sites

Hi ! 

It works ! 

I suspected it had something to do with the fact that two instances coexisted, but I didn't think of using that at all, and I don't remember seeing it anywhere before...

Thanks a lot!

Not all heroes wear capes 🦸

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