Magento Enterprise控制器替代 [英] Magento Enterprise controller override

查看:117
本文介绍了Magento Enterprise控制器替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖Enterprise / CatalogEvent / controllers / Adminhtml / Catalog / EventController.php。

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

问题是config.xml。如何遵循Magento的命名约定。
以下是config.xml文件

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>


推荐答案

基于上面看似正确的xpath和属性,您将需要在Mynamespace / CatalogEvent / controllers / Adminhtml /下有一个EventController.php文件。

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

这种重写方式是Magento中最新的(不推荐使用以前的方法)。实际上,您是在Enterprise目录之前注入目录,并且路由将从此处开始。因为控制器类定义对于自动加载器不可用,所以通过采用模块参数并将其翻译为目录来包含它们。在核心Magento中,控制器文件的路由是通过 Mage_Core_Controller_Varien_Router_Standard :: getControllerFileName() Mage_Core_Model_Config :: getModuleDir()确定的(以及其他)。评估方式意味着在模块中的两个目录级别(例如Mynamespace / CatalogEvent)之后,下一个目录将是 controllers。

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".

确保您的EventController类定义的定义如上所述,您的操作与您要覆盖的操作相匹配,并且您的类名与您的路径相匹配,您将可以正常使用。

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.

这篇关于Magento Enterprise控制器替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆