Magento Enterprise controller override

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

I am trying to override the Enterprise/CatalogEvent/controllers/Adminhtml/Catalog/EventController.php.

The problem is the config.xml. How do I follow the naming convention of Magento. The following is the config.xml file

<admin>
        <routers>
            <adminhtml>
                    <args>
                        <modules>
                            <Mynamespace_catalogevent before="Enterprise_CatalogEvent">Mynamespace_CatalogEvent_Adminhtml</Mynamespace_catalogevent>
                        </modules>
                    </args>
             </adminhtml>
        </routers>
</admin>

Based on the seemingly correct xpath and attribute above, you will need to have an EventController.php file under Mynamespace/CatalogEvent/controllers/Adminhtml/.

This style of rewrite is the latest in Magento (deprecating previous methods). Effectively, you are injecting a directory before the Enterprise directory, and routing will start there. Because controller class definitions are not available to the autoloader, they are included by taking the module argument and translating that to a directory. In core Magento routing though the controller file is determined via Mage_Core_Controller_Varien_Router_Standard::getControllerFileName() and Mage_Core_Model_Config::getModuleDir() (among others). The way that it's evaluated means that after two directory levels in your module (eg. Mynamespace/CatalogEvent), the next directory will be "controllers".

Ensure that your EventController class definition is located according to the above, that your action matches the action you are overriding, and that your classname matches your path, and you'll be good to go.

The difficult thing is that if anything is "off" about your structure and syntax (save the incorrect classname), the router will end up resolving to the Enterprise action controller.

`Reply Or Comment!
Please LogIn to Reply!