Important common Magento Code Tweaks
add new new menu item under system like Export/Import
Open Your modules confix.xml file under adminhtml tag section of your file you can see all the menus are declared there.
You can add any menu in that section :
<menu> <ams module="ams"> <title>Ams</title> <sort_order>71</sort_order> <children> <items module="ams"> <title>Manage Items</title> <sort_order>0</sort_order> <action>ams/adminhtml_ams</action> </items> </children> </ams> <system> <children> <convert> <children> <offers module="ams"> <title>Export Offers</title> <sort_order>0</sort_order> <action>ams/adminhtml_ams/offers</action> </offers> </children> </convert> </children> </system> </menu>
You can see i have added my menu under system >> Import/Export >> Export Offers. For that part you need to see under what tag you need to accomodate then you can see that modules config.xml or adminhtml.xml file.
Note : By Default adminhtml.xml file contain all the menus of admin section.
You can find adminhtml.xml file at app\code\core\Mage\Adminhtml\etc\adminhtml.xml file.
How to hide menu from top menus of admin section
Open Your modules config.xml file.
Comment the menu that you want to get deleted like
<menu> <!--ams module="ams"> <title>Ams</title> <sort_order>71</sort_order> <children> <items module="ams"> <title>Manage Items</title> <sort_order>0</sort_order> <action>ams/adminhtml_ams</action> </items> </children> </ams--> <system> <children> <convert> <children> <offers module="ams"> <title>Export Offers</title> <sort_order>0</sort_order> <action>ams/adminhtml_ams/offers</action> </offers> </children> </convert> </children> </system> </menu>
How to highlight any specific menu once the page of their submenu gets called
Just go to controllers of your module and You will find a function named “_initAction”. Use _setActiveMenu function to highlight your menu like below code
</code> protected function _initAction() { $this->loadLayout() ->_setActiveMenu('system') ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager')); return $this; } <code> </code> <code>
Add a new configuration menu in magento admin
Create configuration for your magento extension
For this add/edit system.xml file under your module
Write your code like this
</code> <config> <tabs> <infogain translate="label" module="ams"> <label>Infogain Extensions</label> <sort_order>100</sort_order> </infogain> </tabs> <sections> <infogain translate="label" module="ams"> <label>Extension Options</label> <tab>infogain</tab> <sort_order>1000</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <groups> <infogain_group translate="label" module="ams"> <label>Web Service Options</label> <frontend_type>text</frontend_type> <sort_order>1000</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <infogain_input translate="label"> <label>Enter WSDL URL: </label> <comment>WSDL URL from where we will update product</comment> <frontend_type>text</frontend_type> <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </infogain_input> </fields> </infogain_group> </groups> </infogain> </sections> </config> <code> </code> <code>
How to get confiration option value in magento code:
How to get data from Magento System Configuration
$configValue = Mage::getStoreConfig(‘sectionName/groupName/fieldName’);
sectionName, groupName and fieldName are present in etc/system.xml file of your module.
Chandra Shekhar
Latest posts by Chandra Shekhar (see all)
- Best practices for micro service design - January 23, 2022
- Spring Boot - January 23, 2022
- Java - January 23, 2022
Recent Comments