Phương Nguyễn
Phương Nguyễn

Reputation: 8905

Cannot set default configuration for magento extension

We are running Magento 1.7.0 and trying to make an extension for that. That extension need a few configurations and we are configure them inside etc/config.xml. The issue is we won't be able to set the default value for these configurations Our fields definitions:

<config>
  <sections>
    <mymodule_options translate="label" module="mymodule_core">
      <label>Mymodule Core Options</label>
      <tab>mymodule_config</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>
        <api translate="label">
          <label>Advanced Options</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>
          <expanded>1</expanded>
          <fields>
            <api_key>
              <label>API 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>
            </api_key>
            <server_host>
              <label>Server Host</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>
            </server_host>
            <server_port>
              <label>Server Port</label>
              <frontend_type>text</frontend_type>
              <sort_order>3</sort_order>
              <show_in_default>1</show_in_default>
              <show_in_website>1</show_in_website>
              <show_in_store>1</show_in_store>
          </server_port>
        </fields>
        </api>
      </groups>
    </mymodule_options>
  </sections>
  <default>
    <mymodule_options>
      <api>
        <server_host>mymodule.herokuapp.com</server_host>
        <server_port>80</server_port>
      </api>
    </mymodule_options>
  </default>              
</config>

Then we drop related rows from core_config_data, then error_log these values: Mage::getStoreConfig('mymodule_options/api/server_host') But what we got is a NULL value. If we set that value inside admin configuration interface to a random value then we get that value anyway. What we did wrong that the default value declaration does not work?

Upvotes: 0

Views: 498

Answers (1)

Kev K
Kev K

Reputation: 234

As R.S says in the comment, your <sections> should go in system.xml and the <default> in config.xml.

Upvotes: 2

Related Questions