As you noticed, these are two different kinds of controller classes. The actual controllers, loaded by the Magento Router, in controllers
and abstract controller classes, loaded by the autoloader in Controller
Controller overrides work as follows:
For each route (like amazon_payments
in your case), several modules can register their controllers:
- The Amazon_Payments module registers their controllers with prefix
Amazon_Payments
- Your module registers its controllers with prefix
KNG_Amazon_Payments
and specifies that they should be used before Amazon_Payments
.
Now for each request that starts with the front name of amazon_payments
, controllers and actions are searched in this order. A request to amazon_payments/onepage/index
will:
- look for
app/code/local/KNG/Amazon/Payments/controllers/OnepageController.php
,
- if the file exists, load it and check if the class
KNG_Amazon_Payments_OnepageController
contains a indexAction
method, if yes, execute it and stop (if this class is not defined in the file, throw an error)
- look for
app/code/community/Amazon/Payments/controllers/OnepageController.php
- if the file exists, load it and check if the class
Amazon_Payments_OnepageController
contains a indexAction
method, if yes, execute it and stop (if this class is not defined in the file, throw an error)
- forward to
noroute
action (i.e. show 404 page)
Abstract Controller
classes:
For abstract controller classes, this override system does not work, you would have to override each single controller and extend the original class, so that all actions use your controllers. This is the same problem that we have with changing methods in abstract model classes. To avoid duplicate code, you could use traits.
But there is another option: Since classes in the Controller
directory are loaded by the autoloader, the directory fallback system can be used. Place your modified abstract controller in app/code/local/Amazon/Payments/Controller/Checkout.php
. It must be a modified copy of the original class, not a new class that extends it.
Both solutions are not very pretty, but if you really need to make changes there, you have to choose the lesser of the two evils.
Think about it twice, if you can accomplish your goal with a different method. If the code in the question is your real and complete code, maybe you can override the singleton instead?
Best Answer
I think your config your be the following:
Since your controller is called
Mymodule_Slider_Adminhtml_SliderController
then I think the section of your config.xml should match and beMymodule_Slider_Adminhtml
.