Abhijeet kumar sharma Abhijeet kumar sharma - 4 months ago 38
PHP Question

How to set external URL link to Magento admin menu

I am working on a module where I have created one menu in Magento admin using

adminhtml.xml
.

Now I want to link one of the menu to an external URL and set
target="blank"
. But I'm not sure how to do it in
adminhtml.xml
. Here is my code.

<?xml version="1.0"?>
<config>
<menu>
<system>
<children>
<convert translate="title">
<children>
<importmagmi translate="title" module="importexport">
<title>MagMi Importer</title>
<action><url helper="https://externalurl.com"/></action>
<sort_order>100</sort_order>
</importmagmi>
</children>
</convert>
</children>
</system>
</menu>
</config>


When i am checking its adding current domain name before external url. ex: http://mydomainname.com/https://externalurl.com

I am wondering how to set only external URL ?

Answer

Inside <action> tag you can put module/controller/action of your module.

Then create this action and put something like this:

public function locationAction()
{
    $this->_redirectUrl('http://www.example.com/');
}

See Mage_Core_Controller_Varien_Action::_redirectUrl for the standard redirect implementation in Magento controller actions.

Comments