gpt4 book ai didi

Magento 管理模块 Controller - 加载另一个 Action

转载 作者:行者123 更新时间:2023-12-02 22:31:35 25 4
gpt4 key购买 nike

我正在尝试为 Magento 创建一个只能从管理区域看到的新模块。

我已经成功创建了模块,现在已经创建了一个名为“editproducts”的 Controller 。在这个 Controller 中,我有 indexAction 和 testAction。

当我转到/quickedit/editproducts/时,它从 Controller 加载 indexAction 非常好,但是当我转到/quickedit/editproducts/test/时,它重定向到仪表板而不调用 testAction。从我看到的教程来看,我似乎已经正确设置了所有内容。

我的 config.xml 文件:

<config>
<modules>
<Test_Quickedit>
<version>0.1.0</version>
</Test_Quickedit>
</modules>

<global>
<helpers>
<quickedit>
<class>Test_Quickedit_Helper</class>
</quickedit>
</helpers>
</global>

<admin>
<routers>
<the_name_of_this_element_is_not_important_it_should_be_unique>
<use>admin</use>
<args>
<module>Test_Quickedit</module>
<frontName>quickedit</frontName>
</args>
</the_name_of_this_element_is_not_important_it_should_be_unique>
</routers>
</admin>

<adminhtml>
<menu>
<menu1 translate="title" module="quickedit">
<title>Test</title>
<sort_order>60</sort_order>
<children>
<menuitem1 module="quickedit">
<title>Edit Products</title>
<action>quickedit/editproducts</action>
</menuitem1>
</children>
</menu1>
</menu>
<acl>
<resources>
<admin>
<children>
<catalog>
<children>
<quickedit_editproducts>
<title>Edit Products</title>
</quickedit_editproducts>
</children>
</catalog>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>

我的 EditproductsController.php

class Test_Quickedit_EditproductsController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
echo 'edit products';
}

public function testAction()
{
echo 'test';
}
}

最佳答案

这只是因为您重定向的 URL 不包含 key

如果您检查管理模块 URL,您会看到 URL 中还添加了一个 key ,因此为了生成正确的 URL,请使用以下代码。

$URL = Mage::helper("adminhtml")->getUrl("mymodule/adminhtml_mycontroller/myaction/",array("param1"=>1,"param2"=>2));

$URL = Mage::helper("adminhtml")->getUrl("mymodule/adminhtml_mycontroller/myaction/");

希望这对您有所帮助!

关于Magento 管理模块 Controller - 加载另一个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12157876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com