php – 如何从Magento中的扩展程序创建的自定义菜单中调用控制器?
作者:互联网
我是Magento的新手,起初我完成了创建Magento Extension的任务.所以我正在从互联网上阅读并创建扩展.我的Magento版本是1.7.0.2.
我能够创建扩展的基本结构,并将config.xml和其他文件保存在适当的位置,这使得我的扩展在Magento中正确安装,但现在我想从我在菜单中的主导航中添加的菜单中调用我的控制器.这是我的config.xml文件,请告诉我这里我做错了什么不让我从我的菜单调用我的控制器.
<?xml version="1.0"?>
<config>
<!-- turn on our module, required for install support -->
<modules>
<Gwb_Magecrmsync>
<version>0.1.0</version>
</Gwb_Magecrmsync>
</modules>
<global>
<helpers>
<magecrmsync>
<class>Gwb_Magecrmsync_Helper</class>
</magecrmsync>
</helpers>
<!-- turn on models -->
<models>
<magecrmsync>
<class>Gwb_Magecrmsync_Model</class>
<resourceModel>Magecrmsync_mysql4</resourceModel>
</magecrmsync>
</models>
<!-- turn on models -->
<!-- turn on database connections -->
<resources>
<!-- setup is needed for automatic installation -->
<magecrmsync_setup>
<use>default_setup</use>
</magecrmsync_setup>
<magecrmsync_write>
<use>default_write</use>
</magecrmsync_write>
<magecrmsync_read>
<use>default_read</use>
</magecrmsync_read>
</resources>
<blocks>
<magecrmsync>
<class>Gwb_Magecrmsync_Block</class>
</magecrmsync>
</blocks>
<layout>
<magecrmsync>
<file>Magecrmsync.xml</file>
</magecrmsync>
</layout>
</global>
<admin>
<routers>
<magecrmsync>
<use>admin</use>
<args>
<module>Gwb_Magecrmsync</module>
<frontName>magecrmsync</frontName>
</args>
</magecrmsync>
</routers>
</admin>
<adminhtml>
<menu>
<menu1 translate="title" module="magecrmsync">
<title>Synchronize</title>
<sort_order>999</sort_order>
<children>
<menuitem1 module="magecrmsync">
<title>Synchronize</title>
<action>magecrmsync/adminhtml_magecrmsync</action>
</menuitem1>
</children>
</menu1>
</menu>
<acl>
<resources>
<admin>
<children>
<menu1 translate="title" module="magecrmsync">
<title>Synchronize</title>
<sort_order>999</sort_order>
<children>
<menuitem1>
<title>Synchronize</title>
</menuitem1>
</children>
</menu1>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
请在此处查看我的更新代码:
How to add custom tab in left sidebar to my custom page in admin section in magento module?
任何帮助,将不胜感激.
谢谢
解决方法:
这是config.xml应该是这样的:
<?xml version="1.0"?>
<config>
<!-- turn on our module, required for install support -->
<modules>
<Gwb_Magecrmsync>
<version>0.1.0</version>
</Gwb_Magecrmsync>
</modules>
<global>
<helpers>
<magecrmsync>
<class>Gwb_Magecrmsync_Helper</class>
</magecrmsync>
</helpers>
<!-- turn on models -->
<models>
<magecrmsync>
<class>Gwb_Magecrmsync_Model</class>
<resourceModel>Magecrmsync_mysql4</resourceModel>
</magecrmsync>
</models>
<!-- turn on models -->
<!-- turn on database connections -->
<resources>
<!-- setup is needed for automatic installation -->
<magecrmsync_setup>
<use>default_setup</use>
</magecrmsync_setup>
<magecrmsync_write>
<use>default_write</use>
</magecrmsync_write>
<magecrmsync_read>
<use>default_read</use>
</magecrmsync_read>
</resources>
<blocks>
<magecrmsync>
<class>Gwb_Magecrmsync_Block</class>
</magecrmsync>
</blocks>
<layout>
<magecrmsync>
<file>Magecrmsync.xml</file>
</magecrmsync>
</layout>
</global>
<admin>
<routers>
<magecrmsync>
<use>admin</use>
<args>
<module>Gwb_Magecrmsync</module>
<frontName>magecrmsync</frontName>
</args>
</magecrmsync>
</routers>
</admin>
<adminhtml>
<menu>
<menu1 translate="title" module="magecrmsync">
<title>Synchronize</title>
<sort_order>999</sort_order>
<children>
<menuitem1 module="magecrmsync">
<title>Synchronize</title>
<action>magecrmsync/adminhtml_synchronize</action>
</menuitem1>
</children>
</menu1>
</menu>
<acl>
<resources>
<admin>
<children>
<menu1 translate="title" module="magecrmsync">
<title>Synchronize</title>
<sort_order>999</sort_order>
<children>
<menuitem1>
<title>Synchronize</title>
</menuitem1>
</children>
</menu1>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
然后在Gwb / Magecrmcync / controllers / Adminhtml中创建一个SynchronizeController.php:
class Gwb_Magecrmsync_Adminhtml_SynchronizeController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
它会以你想要的方式工作.
标签:php,magento,magento-1-7 来源: https://codeday.me/bug/20190709/1410961.html