无法调用 magento 管理控制器
Unable to call magento admin controller
我创建了一个自定义模块,它在目录中添加了两个菜单。我还为 menu 之一创建了一个 controller ,但控制器从未被调用,而是被重定向到管理仪表板页面。
我的问题是一些与这个问题相关的问题Magento admin routing isn't working
我尝试了答案中提到的建议,但 none 对我有用。
每当我打电话给 url http://localhost/compare/index.php/ecomm/index/key/bb9f436ee373421b170aa862a1cbb305/
我被重定向到 http://localhost/compare/index.php/admin/dashboard/index/key/bb9f436ee373421b170aa862a1cbb305/ 并且 hello world 永远不会打印出来。
我正在使用 magento 1.9 并禁用了所有缓存。
我的模块名称是Super_Awesome 下面是目录结构
Super
|
|-Awesome
|-etc (adminhtml.xml, config.xml)
|-controllers (ManageEcomm.php)
|-Helper (Data.php)
app/etc/modules/Super_Awesome.xml中的配置文件如下
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<active>true</active>
<codePool>local</codePool>
</Super_Awesome>
</modules>
</config>
app/code/local/Super/Awesome/etc/config.xml中的配置文件是
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<version>0.1.0</version>
</Super_Awesome>
</modules>
<admin>
<routers>
<ecomm>
<use>admin</use>
<args>
<module>Super_Awesome</module>
<frontName>ecomm</frontName>
</args>
</ecomm>
</routers>
</admin>
<adminhtml>
<!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
<acl>
<resources>
<admin>
<children>
<catalog>
<!--<title>Awesome Menu Item</title>-->
<children>
<example translate="title" module="awesome">
<title>Manage Ecommerce</title>
</example>
<example1 translate="title" module="awesome">
<title>Manage Ecommerce Pages</title>
</example1>
</children>
</catalog>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<global>
<helpers>
<awesome>
<class>Super_Awesome_Helper</class>
</awesome>
</helpers>
</global>
</config>
控制器app/code/local/Super/Awesome/controllers/IndexController.php
<?php
class Super_Awesome_IndexController extends Mage_adminhtml_Controller_Action
{
public function indexAction()
{
echo "hello world";
exit();
}
}
最后 adminhtml.xml 文件在 app/code/local/Super/Awesome/etc/
<?xml version="1.0"?>
<config>
<menu>
<catalog translate="title" module="awesome">
<!--<title>Awesome</title>
<sort_order>15</sort_order>-->
<children>
<example translate="title" module="awesome">
<title>Manage Ecommerce</title>
<sort_order>1</sort_order>
<action>adminhtml/ecomm</action>
</example>
<example1 translate="title" module="awesome">
<title>Manage Ecommerce Pages</title>
<sort_order>2</sort_order>
<action>adminhtml/example/index</action>
</example1>
</children>
</catalog>
</menu>
</config>
我认为您错过了 etc/config.xml
中 add your new module as a router for adminhtml
的部分。它应该是这样的:
When Magento tries to find a controller file for an admin URL, it will also check for any module configured inside this <modules/>
tag.
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Super_Awesome after="Mage_Adminhtml">Super_Awesome</Super_Awesome>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
我终于痛苦地发现自己创建一个模块并不好。如果你犯了一个错误,你可能会浪费宝贵的时间去寻找哪里出了问题。
最好安装来自 Ultimate Module Creator or use a online tool provided by Silk
的模块创建器扩展
我创建了一个自定义模块,它在目录中添加了两个菜单。我还为 menu 之一创建了一个 controller ,但控制器从未被调用,而是被重定向到管理仪表板页面。
我的问题是一些与这个问题相关的问题Magento admin routing isn't working
我尝试了答案中提到的建议,但 none 对我有用。
每当我打电话给 url http://localhost/compare/index.php/ecomm/index/key/bb9f436ee373421b170aa862a1cbb305/
我被重定向到 http://localhost/compare/index.php/admin/dashboard/index/key/bb9f436ee373421b170aa862a1cbb305/ 并且 hello world 永远不会打印出来。
我正在使用 magento 1.9 并禁用了所有缓存。
我的模块名称是Super_Awesome 下面是目录结构
Super | |-Awesome |-etc (adminhtml.xml, config.xml) |-controllers (ManageEcomm.php) |-Helper (Data.php)
app/etc/modules/Super_Awesome.xml中的配置文件如下
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<active>true</active>
<codePool>local</codePool>
</Super_Awesome>
</modules>
</config>
app/code/local/Super/Awesome/etc/config.xml中的配置文件是
<?xml version="1.0"?>
<config>
<modules>
<Super_Awesome>
<version>0.1.0</version>
</Super_Awesome>
</modules>
<admin>
<routers>
<ecomm>
<use>admin</use>
<args>
<module>Super_Awesome</module>
<frontName>ecomm</frontName>
</args>
</ecomm>
</routers>
</admin>
<adminhtml>
<!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
<acl>
<resources>
<admin>
<children>
<catalog>
<!--<title>Awesome Menu Item</title>-->
<children>
<example translate="title" module="awesome">
<title>Manage Ecommerce</title>
</example>
<example1 translate="title" module="awesome">
<title>Manage Ecommerce Pages</title>
</example1>
</children>
</catalog>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<global>
<helpers>
<awesome>
<class>Super_Awesome_Helper</class>
</awesome>
</helpers>
</global>
</config>
控制器app/code/local/Super/Awesome/controllers/IndexController.php
<?php
class Super_Awesome_IndexController extends Mage_adminhtml_Controller_Action
{
public function indexAction()
{
echo "hello world";
exit();
}
}
最后 adminhtml.xml 文件在 app/code/local/Super/Awesome/etc/
<?xml version="1.0"?>
<config>
<menu>
<catalog translate="title" module="awesome">
<!--<title>Awesome</title>
<sort_order>15</sort_order>-->
<children>
<example translate="title" module="awesome">
<title>Manage Ecommerce</title>
<sort_order>1</sort_order>
<action>adminhtml/ecomm</action>
</example>
<example1 translate="title" module="awesome">
<title>Manage Ecommerce Pages</title>
<sort_order>2</sort_order>
<action>adminhtml/example/index</action>
</example1>
</children>
</catalog>
</menu>
</config>
我认为您错过了 etc/config.xml
中 add your new module as a router for adminhtml
的部分。它应该是这样的:
When Magento tries to find a controller file for an admin URL, it will also check for any module configured inside this
<modules/>
tag.
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Super_Awesome after="Mage_Adminhtml">Super_Awesome</Super_Awesome>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
我终于痛苦地发现自己创建一个模块并不好。如果你犯了一个错误,你可能会浪费宝贵的时间去寻找哪里出了问题。
最好安装来自 Ultimate Module Creator or use a online tool provided by Silk
的模块创建器扩展