nik Posted January 17, 2020 Share Posted January 17, 2020 Hi! I would like to override /controllers/admin/AdminOrdersController.php, in order to change some minor functionality only in the postProcess() class, but I am not sure how to do it correctly. What I would do is just placing a new AdminOrdersController.php file under the same /override path with following content: class AdminOrdersController extends AdminOrdersControllerCore { public function postProcess() { //copy all the code of the function, including my adjustment } } Now, why am I having concerns: 1) on the top of the original controller following code exists and I am not sure about how to deal with it in my overriden controller class BoOrder extends PaymentModule { public $active = 1; public $name = 'bo_order'; public function __construct() { $this->displayName = $this->trans('Back office order', array(), 'Admin.Orderscustomers.Feature'); } } use PrestaShop\PrestaShop\Adapter\StockManager; /** * @property Order $object */ class AdminOrdersControllerCore extends AdminController { ....... 2) To I have to deal with constructors as well? Or call any function from the parent controller? Thanks in advance, Nikos Link to comment Share on other sites More sharing options...
tomerg3 Posted January 17, 2020 Share Posted January 17, 2020 You do not need any other code, just what you wrote above, and the actual function you wish to change. One thing to note, if the original function has the line parent::function();, you will need to keep it, but replace "parent" with the class that AdminOrdersControllerCore extends. Link to comment Share on other sites More sharing options...
nik Posted January 18, 2020 Author Share Posted January 18, 2020 Seems to have worked! Link to comment Share on other sites More sharing options...
tomerg3 Posted January 18, 2020 Share Posted January 18, 2020 10 hours ago, nik said: Seems to have worked! Happy to help Link to comment Share on other sites More sharing options...
nik Posted January 21, 2020 Author Share Posted January 21, 2020 Actually, the above approach has worked for every class and controller I overrode, except one place: /classes/controller/AdminController.php There I wanted to override the init() function in order to extend the cookie timeout. class AdminController extends AdminControllerCore { public function init() { Controller::init(); // replaced original code: parent::init(); ... if ($this->context->cookie->last_activity + 10000 < time()) { //if ($this->context->cookie->last_activity + 900 < time()) { ... ... } } But it didn't work, prestashop backoffice won't load at all. Link to comment Share on other sites More sharing options...
tomerg3 Posted January 21, 2020 Share Posted January 21, 2020 Did you try to enable debug mode, possibly you have a syntax error. Link to comment Share on other sites More sharing options...
50l3r Posted May 12, 2021 Share Posted May 12, 2021 In Prestashop 1.7.7.4 AdminOrdersController it doesnt exist. How can i do this? 1 Link to comment Share on other sites More sharing options...
Experience of Design Posted September 29, 2021 Share Posted September 29, 2021 Class named AdminOrdersControllerCore for overriding. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now