0

Magento 1.9

I want to create a new tab in System > Configuration. In this tab, I need a group tab and in this group tab i want a textarea which is connected to a field of my database. If i edit my textarea, it will modify my database field too.

Look at this: https://prnt.sc/orwph1

I don't know how to connect my textarea with my db.. Create a new tab with a new group it's easy but connect it to the db..

Thanks!

  • What are you doing with the database field. Can you please elaborate more? – Abdul Pathan Aug 13 '19 at 8:56
  • I just want that the content of my textarea is my database field. – Theo Cerutti Aug 13 '19 at 9:18
  • System Config fields are already getting stored in database. Why cant you get it directly with Mage::getStoreConfig('sectionName/groupName/fieldName') wherever your logic needs it?? Am I missing something ? – Abdul Pathan Aug 13 '19 at 10:04
  • 'System Config fields are already getting stored in database.', i didn't know...Thanks! – Theo Cerutti Aug 13 '19 at 11:00
  • I have added answer for you, please see if it helps you to finds solution quicker. – Abdul Pathan Aug 13 '19 at 12:05
2

Magento provides inbuild option to create custom config fields. Magento take care by itself for storing and retrieving data from database. You can create custom config field as 1. Create a new system.xml in your modules etc folder. 2. Put the content in system.xml as

<config>
    <tabs>
    <!--This will create a new Tab for you-->
        <customtab translate="label" module="helloworld">
            <label>Tab Name</label>
            <sort_order>99999</sort_order>
        </customtab>
    </tabs>    
    <sections>
        <!--This will create a new Section for Tab-->
        <custom_section translate="label" module="helloworld">
            <label>Custom Group - General</label>
            <tab>customtab</tab> <!--See the tab name matches above tab-->
            <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>
        <groups>
        <!--This will create a new Group for Tab-->
                <general translate="label comment" module="ordercron">
                    <label>General 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>
            <!--This will create a new field in above group-->  
                    <custom_field translate="label">
                        <label>Custom Config Fields</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>                
                    </custom_field>
                    </fields>
                </general>
            </groups>
        </custom_section>
    </sections>   
</config>
  1. Now you can access the stored data anywhere as

Mage::getStoreConfig('custom_section/general/custom_field');

and for accessing store specific information use

Mage::getStoreConfig('custom_section/general/custom_field',$storeId);

For more information please refer https://alanstorm.com/custom_magento_system_configuration/

Hope it finds you helpful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.