问题
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>
回答1:
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.
回答2:
I was having a similar issue, and the simple solution to my problem was to ensure that the _Adminthml
portion of the class was included in both my local controller as well as the controller I was overridding. In your case:
<Mynamespace_catalogevent before="Enterprise_CatalogEvent_Adminhtml">
Mynamespace_CatalogEvent_Adminhtml
</Mynamespace_catalogevent>
Your example is missing the _Adminhtml
on the before
attribute.
This is on Magento Enterprise v1.12.0.2
Hope this helps.
来源:https://stackoverflow.com/questions/8007210/magento-enterprise-controller-override