Jump to content

How to override AdminOrdersController.php


Recommended Posts

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,


Link to comment
Share on other sites

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

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()
	// 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

  • 1 year later...
  • 4 months later...

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