1

I have a module that needs smtp authentication information (host, email, method, password, port). I don't want to just hard code this. Where can I put this information where it will have some independence from the code.

For instance, if I wanted to make a JSON that holds this data, where would I place this file in the module structure?

1 Answer 1

1

Magento 1 answer

Magento keeps such information in config.xml files. You can create a config/default section with your information.

Example:

<config>
  ...
  <default>
    <my_module>
      <general>
        <my_setting>my_value</my_setting>
        <my_setting2>my_value2</my_setting2>
      </general>
    </my_module>
  </default>
</config>

If you want to allow the admin to change default values you can use a system.xml file for backend config, but please see some tutorial on how to do it because it is too long to explin in a post.

2
  • That makes a lot of sense. Bonus question, what is the simplest and/or most reliable way to call that from a modules model or controller?
    – Goose
    Feb 16, 2016 at 22:40
  • 1
    There is only one way ;) : Mage::getStoreConfig('my_module/general/my_setting'); Feb 16, 2016 at 22:42

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.