4

I need some urgent information, I want to save data from my custom module in my database. I did some part but i don't know further Process. Please Help Me Guys.

This Is my system.xml file-

<config>
  <sections>
    <earthfedex translate="label">
      <class>separator-top</class>
      <label>Fedex</label>
      <tab>catalog</tab> <!-- the important one -->
      <sort_order>400</sort_order>
      <show_in_default>1</show_in_default>
      <show_in_website>1</show_in_website>
      <show_in_store>1</show_in_store>
      <groups>
                <settings translate="label">
                    <label>General Settings</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>


                    <fields>

                        <active translate="label">
                            <label>Enable Fedex Extension</label>
                            <frontend_type>select</frontend_type>
                            <config_path>fedex/fedex_acc/active</config_path>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <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>
                        </active>
                       </fields>
                    </settings>



                     <fedex_acc translate="label">
                    <label>Fedex Account Details</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>2</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <key translate="label" >
                            <label>Key</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>

                    </key>

                      <pass translate="label">

                            <label>Password</label>
                        <frontend_type>password</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>

                   </pass>

                     </fields>
                 </fedex_acc>
             </groups>
         </earthfedex>
     </sections>
 </config>

I want to store values from 2 fields 1.Fedex Account Password 2.Password

How to do this? If you want any information please let me know. Thank You

2
  • system config data is always saved in database and yo can retrive it using Mage::getStoreConfig ('path/to/fields', Mage::app()->getStore())) Commented Jul 31, 2015 at 12:39
  • ok. but what about table? i have sql query under sql folder which create one table earth_fedex_seeting. and no data i have found there..could you plz explain in depth? Commented Jul 31, 2015 at 13:17

1 Answer 1

7

Add <backend_model> tag in to your field.

Backend Model – a class which allows to operate with configuration data on the different stages (save, load).

It contains three major methods respectively for each event: _afterLoad(), _beforeSave() and _afterSave().

So you can use _afterSave() method.

Eg :

<addresses>
    <label>Blocked Email Addresses</label>
    <backend_model>yourmodule/system_config_backend_yourfile</backend_model>
    <sort_order>2</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>0</show_in_website>
    <show_in_store>0</show_in_store>
</addresses>

Backend Model Class :

<?php

class Namespace_YourModule_Model_System_Config_Backend_Yourfile extends Mage_Core_Model_Config_Data
{
    protected function _afterSave()
    {
        if (is_array($this->getValue())) {
            /* You can perform your logic here */
        }
    }
} 

I have Refer this Link

2
  • cloud you please explain the logic in detail? Commented Jul 31, 2015 at 13:16
  • Refer that link.you'll get better understanding Commented Jul 31, 2015 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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