Magento Expert Forum - Improve your Magento experience

Results 1 to 16 of 16

Customizing Magento System Configuration. Part 2

  1. #1
    Junior Member ccvv's Avatar
    Join Date
    Mar 2013
    Posts
    64
    Thanks
    6
    Thanked 17 Times in 13 Posts

    Default Customizing Magento System Configuration. Part 2

    Before reading this tutorial please check these tutorials if you has not read yet:

    Magento system settings overview

    Customizing Magento System Configuration. Part 1

    Today we will customize tabs and sections, groups and fields without using system.xml.

    Certainly, we know that Magento has a great event system and this knowledge will help us to make changes in the System Configuration.

    For our purposes, we will create a new module and call it ‘SystemConfig’. It consists of three files. First of them is for initialing our module:
    app/etc/modules/Atwix_SystemConfig.xml

    HTML Code:
    <?xml version="1.0"?>
    <config>
        <modules>
            <Atwix_SystemConfig>
                <active>true</active>
                <codePool>local</codePool>
            </Atwix_SystemConfig>
        </modules>
    </config>
    Afterwards, we need to create module configuration file. That is the second one:
    app/code/local/Atwix/SystemConfig/etc/config.xml
    HTML Code:
    <?xml version="1.0"?>
    <config>
        <modules>
            <Atwix_SystemConfig>
                <version>1.0.0</version>
            </Atwix_SystemConfig>
        </modules>
        <global>
            <models>
                <atwix_systemconfig>
                    <class>Atwix_SystemConfig_Model</class>
                </atwix_systemconfig>
            </models>
            <events>
                <adminhtml_init_system_config>
                    <observers>
                        <atwix_init_system_config>
                            <class>atwix_systemconfig/observer</class>
                            <method>changeSystemConfig</method>
                        </atwix_init_system_config>
                    </observers>
                </adminhtml_init_system_config>
            </events>
        </global>
    </config>
    However, let’s check what we have now. So, in the configuration file we define model, configure event, and also, the event ‘adminhtml_init_system_config’ which makes possible to work with System Configuration data.

    And, the third one, the last file – it is an observer, where we do all the magic: app/code/local/Atwix/SystemConfig/Model/Observer.php

    PHP Code:
    <?php
     
    class Atwix_SystemConfig_Model_Observer
    {
        public function 
    changeSystemConfig(Varien_Event_Observer $observe)
        {
            
    $config $observe->getConfig();
     
            return 
    $this;
        }
    }
    Okey, we put debug breakpoint to the line with the return statement and have a good inspect of the picture being used:



    Check this out!

    In the config, there are all the tabs and sections, and in the section – groups and fields, but what about to try some changes. For example, let’s change sort order and label for ‘advanced’ tab and add a comment to the ‘Startup Page’ field.

    Thuswise, at first – change code in the observer: app/code/local/Atwix/SystemConfig/Model/Observer.php


    PHP Code:
    <?php
     
    class Atwix_SystemConfig_Model_Observer
    {
        public function 
    changeSystemConfig(Varien_Event_Observer $observer)
        {
            
    //get init sections and tabs
            
    $config $observer->getConfig();
     
            
    //get tab 'advanced', change sort order and label
            
    $advancedTab $config->getNode('tabs/advanced');
            
    $advancedTab->sort_order 1;
            
    $advancedTab->label .= ' (on top)';
     
            
    //get field 'page', add comment
            
    $config->getNode('sections/admin/groups/startup/fields/page')->comment 'after successful login you will see this page';
     
            return 
    $this;
        }
    }


    Great, advanced tab on the top!

    After what, it is possible to make a lot of changes.

    Moreover, we can also create tabs and section, group and field, besides that, using Mage_Core_Model_Config_Element class we are able to work with elements: create, edit, append, extend, etc. And the next example shows us how to add a new group with the fields to the ‘admin’ section. In this case, the observer should have the following code: app/code/local/Atwix/SystemConfig/Model/Observer.php

    PHP Code:
    <?php
     
    class Atwix_SystemConfig_Model_Observer
    {
        public function 
    changeSystemConfig(Varien_Event_Observer $observer)
        {
            
    //get init sections and tabs
            
    $config $observer->getConfig();
     
            
    //get tab 'advanced', change sort order and label
            
    $advancedTab $config->getNode('tabs/advanced');
            
    $advancedTab->sort_order 1;
            
    $advancedTab->label .= ' (on top)';
     
            
    //get field 'page', add comment
            
    $config->getNode('sections/admin/groups/startup/fields/page')->comment 'after successful login you will see this page';
     
            
    //add new group with fields in section 'admin'
            
    $adminSectionGroups $config->getNode('sections/admin/groups');
            
    $new_group_xml = new Mage_Core_Model_Config_Element('
                <atwix_new_group>
                    <label>New Group</label>
                    <sort_order>99</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                            <disable_message>
                                <label>Disable Message</label>
                                <frontend_type>select</frontend_type>
                                <source_model>adminhtml/system_config_source_yesno</source_model>
                                <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>
                            </disable_message>
                            <message>
                                <label>Message</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>
                                <depends>
                                    <disable_message>0</disable_message>
                                </depends>
                            </message>
                    </fields>
                </atwix_new_group>
            '
    );
            
    $adminSectionGroups->appendChild($new_group_xml);
     
            return 
    $this;
        }
    }


    But, if we wish it is possible to implement a lot of things and reinvent the wheel =)

    At the same time, it will be highly helpful to make some changes in the System Configuration while using the observer.

    Source: Atwix

    View more threads in the same category:


  2. #2
    New member
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    HI All,

    How can i add post a thread here??

    Can anyone post URL TO POST THREAD here for me so i can post a thread???

  3. #3
    New member
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have a store, I am using "Subscribe aheadworks extension" to create subscription products. For recurring payment, i am using paypal pro. Now i want to send invoice on each occurrence of payment. Please help me out on this.

  4. #4
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Default

    Quote Originally Posted by Er Gazzy View Post
    I have a store, I am using "Subscribe aheadworks extension" to create subscription products. For recurring payment, i am using paypal pro. Now i want to send invoice on each occurrence of payment. Please help me out on this.
    Hi Er Gazzy, to make sure we have a very high quality of "Documents and Tutorial" part of this forum. This part category is limited only for mod and admin can add new thread. To add new thread for any question, please use this category http://magentoexpertforum.com/forumd...ming-Questions

    Thanks and sorry for this inconvenience.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    635
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    To Create system.xml.
    Step 1: Create System.xml.
    Step 2: Set default value.
    Step 3: Flush Magento Cache.
    Step 4: Get value from configuration.
    4.1 Simple calling:
    4.2 Create a helper file (standard)

  6. #6

  7. #7
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mmm.. good to be here in your article or post, whatever, I think I should also work hard for my own website like I see some good and updated working in your site. Cutco

  8. #8
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article. Cutco

  9. #9
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This post is very simple to read and appreciate without leaving any details out. Great work! Cutco

  10. #10
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Welcome to the party of my life here you will learn everything about me. Cutco

  11. #11
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. Cutco

  12. #12
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Truly, this article is really one of the very best in the history of articles. I am a antique ’Article’ collector and I sometimes read some new articles if I find them interesting. And I found this one pretty fascinating and it should go into my collection. Very good work! Cutco

  13. #13
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up.. Touchstone Crystal Reviews

  14. #14
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I read that Post and got it fine and informative. Please share more like that... Touchstone Crystal Reviews

  15. #15
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I really enjoy reading and also appreciate your work. Touchstone Crystal Reviews

  16. #16
    Junior Member
    Join Date
    Mar 2021
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject? Touchstone Crystal Reviews

Similar Threads

  1. Customizing Transactional Emails for Magento
    By golddev in forum Webmaster & Administrator
    Replies: 4
    Last Post: 07-04-2021, 06:33 AM
  2. Customizing Magento System Configuration. Part 1
    By ccvv in forum Programming & Development
    Replies: 2
    Last Post: 19-09-2019, 07:26 AM
  3. Magento Module Development - Part 6 - System.xml Advance and Module
    By rocker in forum Programming & Development
    Replies: 1
    Last Post: 29-05-2013, 12:10 PM
  4. Magento Module Development - Part 5 - System.xml and Module
    By rocker in forum Programming & Development
    Replies: 0
    Last Post: 29-04-2013, 02:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •