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.

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. CuteHits.com is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at gmail.com Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...