Magento Enterprise 控制器覆盖

发布于 2024-12-13 22:05:08 字数 621 浏览 1 评论 0原文

我试图覆盖 Enterprise/CatalogEvent/controllers/Adminhtml/Catalog/EventController.php。

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

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小女人ら 2024-12-20 22:05:08

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

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

确保您的 EventController 类定义根据上述内容定位,您的操作与您要覆盖的操作匹配,并且您的类名与您的路径匹配,然后您就可以开始了。

困难的是,如果您的结构和语法有任何问题(保存不正确的类名),路由器最终将解析为企业操作控制器。

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.

梦罢 2024-12-20 22:05:08

我遇到了类似的问题,解决我的问题的简单方法是确保该类的 _Adminthml 部分包含在我的本地控制器以及我要覆盖的控制器中。在您的情况下:

<Mynamespace_catalogevent before="Enterprise_CatalogEvent_Adminhtml">
    Mynamespace_CatalogEvent_Adminhtml
</Mynamespace_catalogevent>

您的示例在 before 属性上缺少 _Adminhtml

这是 Magento Enterprise v1.12.0.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文