Kristian Vitozev
Kristian Vitozev

Reputation: 5971

How to get URL of admin controller method in Magento?

I have the following file structure:

community/Sandipan community/Sandipan/controllers/Adminhtml/ProductfileuploadbackendController.php [1]

I have a template file in the following directory:

design/adminhtml/default/default/template/productfileupload/catalog/product/tab.phtml [2]

My class [1] looks like this:

class Sandipan_Productfileupload_Adminhtml_ProductfileuploadbackendController extends Mage_Adminhtml_Controller_Action {

    public method deleteRecordAction() {

    }

}

I want to send AJAX request to deleteRecordAction from my template [2], how can I do that? I tried the following:

Mage::helper("adminhtml")>getUrl("adminhtml/productfileuploadbackend/deleteRecord");

But it's not working.

Upvotes: 1

Views: 1060

Answers (1)

Amit Bera
Amit Bera

Reputation: 7611

If your module config.xml configure is properly and configure like

<config>
....
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Sandipan_Productfileupload before="Mage_Adminhtml">Sandipan_Productfileupload_Adminhtml</Sandipan_Productfileupload>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
....    
</config>

Then

Mage::helper('adminhtml')->getUrl('adminhtml/productfileuploadbackend/deleteRecord', array('_secure' => true);

should work properly

Upvotes: 3

Related Questions