Skip to content

Autoload and Extended Magento Core Controllers

You’ll spend a lot of time extending existing classes when you work with Magento to take advantage of the copious built-in functionality. Here is a ‘gotcha’ when extending controllers:

If you’re extending a ‘core’ factory controller, like so:

class YourPackage_YourModule_IndexController extends Mage_Adminhtml_Controller_Action

…then Adminhtml controller will autoload. However, if you’re extending a controller class that is itself extended from a ‘core’ factory controller, like so:

class YourPackage_YourModule_IndexController extends Mage_Adminhtml_Report_SalesController

…then the SalesController will not autoload. You must include it, like:

//refuses to autoload
require_once("Mage/Adminhtml/controllers/Report/SalesController.php");

class YourPackage_YourModule_IndexController extends Mage_Adminhtml_Report_SalesController

If you’re having trouble getting access to the controller class that you’ve extended, this may be the problem.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*