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

标签 magento module controller admin

我正在尝试为 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 - 加载另一个操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12157876/

相关文章:

php - Magento 继承链。好的还是坏的做法?

javascript - JQUERY 每个按钮后的第一个元素

sql - Magento 自定义模块中的完整性约束违规

python - 我应该停止使用已弃用的模块吗?

jquery - ASP.NET MVC - 路由仍然让我感到困惑

php - Controller 类存在但未找到

php - 保存现有可配置项时出现完整性约束冲突错误

perl - 在 Perl 中,如何检查给定函数是从哪个模块导入的?

linux - 使用mkfile编译linux内核模块

authentication - Play Framework : How to require login for some actions, 但不是全部