Jump to content

Can't get controller overriding to work


Dave Riley

Recommended Posts

PS: 1.5.6.1

 

I'm trying to override AdminOrdersController, specifically the class's constructor in order to add a column for shipping to the orders list.

 

I created a copy of controllers\admin\AdminOrdersController.php and put it in \override\controllers\admin. I changed the class definition at the top from:

   class AdminOrdersControllerCore extends AdminController

to:

  class AdminOrdersController extends AdminOrdersControllerCore

then added in my extra column (BTW if I just edit AdminOrdersController.php in place the added column works fine though in this case I obviously don't change the class definition).

 

I deleted cache\class_index.php and refreshed the orders page but the new column didn't show up.

 

What am I doing wrong?

 

Thanks!

 Dave

Link to comment
Share on other sites

  • 10 months later...
  • 3 months later...

I encountered several things:

- check override path

- check class name

 

With debug mode turned on you can also modify the cache/class_index file directly having something like this:

  'AdminFeaturesController' => 
  array (
    'path' => 'override/controllers/admin/AdminFeaturesController.php',
    'type' => 'class',
    'override' => true,
  ),

in order to force an override 

Link to comment
Share on other sites

  • 2 months later...

Just in case somebody find this usefull,

 

I followed the same steps that Dave wrote and I got override the class AdminOrdersControllerCore, the only difference I see is I'm working on PS 1.6

 

 

 

Path of core class:

controllers/admin/AdminOrdersController.php

Path of override class:

override/controllers/admin/AdminOrdersController.php

Main definition override class

class AdminOrdersController extends AdminOrdersControllerCore

Edited by David_Presta (see edit history)
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...