简体   繁体   中英

Prestashop 1.6 override admincontroller

I am trying to hide the 'help' button on the dashboard by override. But the override is not being used. So I was wondering what am I doing wrong? Why is the override not used?

I found it in: classes/controller/AdminController.php . Then I created a new file: override/classes/controller/AdminController.php .

I could not get the override to work, so I tried to check if it was taken into account at all by:

<?php
class AdminControllerCoreOverride extends AdminControllerCore
{
echo 'askdjfkdjfksl';
}
?>

But nothing happened. I deleted cache: index_cache and the override is not turned off in performance menu. In the index_cache.php I found the AdminController but override was false.

PS: using Prestashop 1.6

If you create an override file manually, you must delete the file cache/class_index.php for your override file to work.

Then, in override/classes/controller/AdminController.php you must override a function like so:

<?php
class AdminController extends AdminControllerCore
{
    public function initPageHeaderToolbar()
    {
        Your code
    }
}

You don't need to put ?> at this end of this file.

I faced similar issue (with PS7). In my case the problem was caused by file permission. Prestashop needs write permision to the file you want to override. Otherwise the file is ignored without any warning/error message. You can delete class_index.php file like crazy with no help.

Also, for some reason, I had to reset my module anytime I do anychange in my override controller.

BTW in PS7 the cache_index is located under /app/cache/dev folder (and /app/cache/prod folder).

you can try this:

update your class name from AdminCoreControllerOverride to AdminCoreOverrideController

and AdminControllerCore to AdminController

<?php
  class AdminCoreOverrideController extends AdminController
  {
     public function init() {
         parent::init();
     }
  }

then you can test in your browser by this link:

http://localhost/YOUR_ADMIN_DIR/index.php?controller=AdminCoreOverride

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM