Tuesday 12 May 2015

How to Use Magento Settings to Manage an Extension Settings?

Whenever you want to make small changes within a particular module or extension in Magento, you have to locate the module configuration tab, and make the necessary changes there. Locating, managing, and making the changes is a tedious process, which you can avoid if you transfer the necessary settings to the main Magento settings. So, you just need to make the modifications within the main settings file, and all the changes are registered.



Create System.xml File

Begin the whole process by creating system.xml file in the etc folder of Magento.

<config> 
    <sections> 
        <pos module="pos"> 
            <label>Example Pos Settings</label> 
            <tab>service</tab> 
            <frontend_type>text</frontend_type> 
            <show_in_default>1</show_in_default> 
            <show_in_website>1</show_in_website> 
            <show_in_store>1</show_in_store> 
            <sort_order>10</sort_order> 
            <groups> 
                <settings translate="label"> 
                    <label>example Pos Settings</label> 
                    <frontend_type>text</frontend_type> 
                    <sort_order>10</sort_order> 
                    <show_in_default>1</show_in_default> 
                    <show_in_website>1</show_in_website> 
                    <show_in_store>1</show_in_store> 
                    <fields> 
                        <sanalpos_url translate="label"> 
                            <label>Service Url</label> 
                            <frontend_type>text</frontend_type> 
                            <sort_order>10</sort_order> 
                            <show_in_default>1</show_in_default> 
                            <show_in_website>1</show_in_website> 
                            <show_in_store>1</show_in_store> 
                        </sanalpos_url> 
                        <user_id translate="label"> 
                            <label>User Id</label> 
                            <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> 
                        </user_id> 
                    </fields> 
                </settings> 
            </groups> 
        </pos> 
    </sections> 
</config> 

Integrate to Config.xml File

This file contains all the field settings required to modify the extension you have created. While Magento is definitely open source, you don’t want to make all the settings and code public. So, you will need to integrate the individual settings to the core settings page.

Paste the following code to the config.xml file
<config> 
    <!-- some more code here --> 
    <adminhtml> 
        <acl> 
            <resources> 
                <all> 
                    <title>Allow Everything</title> 
                </all> 
                <admin> 
                    <children> 
                        <system> 
                        <children> 
                               <config> 
                                   <children> 
                                       <pos> 
                                            <title>Kartaca Pos Settings</title> 
                                            <sort_order>10</sort_order> 
                                       </pos> 
                                   </children> 
                                </config> 
                            </children> 
                        </system> 
                    </children> 
                </admin> 
            </resources> 
        </acl> 
    </adminhtml> 
    <!-- some more code here... --> 
</config> 

With this long xml code, you would enjoy not having to search through individual files and changing the codes there. Saves a lot of time!

Conclusion
Isn’t having one code file an easier way out, especially when it comes to introducing changes, than having multiple files and searching for the particular file? With this integration code, you can easily integrate the codes for the different extensions into your core file. So, you just need to deal with the core file, whenever you want to initiate small changes. Saves a lot of time and effort!

Author Bio:


Deepa is a passionate blogger associated with Silver Touch Technologies., a leading Magento Development Company UK. She recommends checking out Magento Development Services at https://www.silvertouchtech.co.uk. If you are looking to hire Magento developer UK then just get in touch with her.

No comments:

Post a Comment