如何在magento中覆盖adminhtml控制器action.php?

时间:2016-01-13 12:28:06

标签: php magento

我想在adminhtml控制器action.php

中覆盖

这是我到目前为止所尝试的内容:

config.xml中

<args>
     <modules>
          <Medma_MarketPlace before="Mage_Adminhtml">Medma_MarketPlace</Medma_MarketPlace>
     </modules>
</args>

我的Medma / Marketplace / controllers / adminhtml / action.php的代码

require_once "Mage/Adminhtml/controller/Action.php";

class Medma_MarketPlace_Adminhtml_ActionController extends Mage_Adminhtml_Controller_ActionController 
{
   // do something
}

但没有任何反应。我想我做错了什么。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

Arvind,请检查你是否正确编写了配置行,args必须在adminhtml标签内,如下所示:

$(function(){
    $(document).on('click', 'a.favIt', function(e){
        e.preventDefault();
        var itemId = $(this).attr('id').split("_")[1],
            csrf = $('[name=csrfmiddlewaretoken]').val();
        if (!csrf) console.log("You must add {% csrftoken %} somewhere in the template.");
        $.ajax({
            type: "POST",
            url: $(this).attr("data-action-url"),
            data: {'csrfmiddlewaretoken': csrf},
            dataType: "json",
            timeout: 2000,
            cache: false,
            beforeSend: function(XMLHttpRequest) {
                //$("#loader").fadeIn();
            },
            error: function(data, XMLHttpRequest, textStatus, errorThrown){
                $(this).html("Error connecting to the server.");
            },
            complete: function(XMLHttpRequest, textStatus) {
                //$("#loader").fadeOut();
            },
            success: function(data, textStatus, XMLHttpRequest){
                $('#FavIt_'+itemId).html(data.message);
                $('#FavCounter_'+itemId).html(data.counter);
            }
        });
    });
});

希望这有帮助。