2012-11-23 54 views
0

我們正在運行Magento 1.7.0並試圖爲此擴展。該擴展需要一些配置,我們將它們配置在etc/config.xml中。 的問題是,我們將無法設置默認值對於這些配置 我們的字段的定義:無法爲magento擴展設置默認配置

<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> 

從core_config_data然後我們放棄相關行,那麼這些是error_log值: Mage::getStoreConfig('mymodule_options/api/server_host') 但我們得到了什麼是一個NULL值。如果我們在管理配置界面中將該值設置爲隨機值,那麼我們就可以得到該值。我們做錯了,默認值聲明不起作用?

+1

上面的代碼是在system.xml還是config.xml中?到目前爲止,我所看到的所有示例在config.xml中總是有''..例如http://blog.chapagain.com.np/magento-add-default-value-to-system-configuration-option-fields/ –

回答

2

正如R.S在評論中所說,您的<sections>應該在system.xml中,而在config.xml中則應該是<default>