2011-05-01 11 views

Respuesta

32

Puede agregar el valor predeterminado a la opción de configuración de administrador a través del archivo config.xml de su módulo. Por la opción de configuración de administrador, entiendo que se refiere a las opciones de configuración de configuración (Sistema -> Configuración).

Supongamos que tiene el siguiente archivo system.xml. El archivo System.xml es necesario para agregar opciones de configuración de administrador.

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <sections>   
     <mysection translate="label" module="mymodule"> 
      <label>My Section</label> 
      <tab>catalog</tab> 
      <frontend_type>text</frontend_type> 
      <sort_order>110</sort_order> 
      <show_in_default>1</show_in_default> 
      <show_in_website>1</show_in_website> 
      <show_in_store>1</show_in_store> 
      <groups> 
       <mygroup translate="label" module="mymodule"> 
        <label>My Group</label> 
        <frontend_type>text</frontend_type> 
        <sort_order>99</sort_order> 
        <show_in_default>1</show_in_default> 
        <show_in_website>1</show_in_website> 
        <show_in_store>1</show_in_store> 
        <fields> 
         <myfield translate="label comment"> 
          <label>My Field</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> 
         </myfield>      
        </fields> 
       </mygroup> 
      </groups>   
     </mysection>    
    </sections> 
</config> 

Ahora, para agregar valor predeterminado para las opciones de configuración de administrador, tiene que escribir lo siguiente en config.xml archivo de su módulo.

<default> 
    <mysection> 
     <mygroup>     
      <myfield>My Default Value</myfield>   
     </mygroup>  
    </mysection> 
</default> 

Espero que esto ayude.

Para una explicación detallada, puede hacer referencia a: - http://alanstorm.com/magento_default_system_configuration_values

+0

esto no parece funcionar para mí. He lavado mi memoria caché, el caché de almacenamiento, he ingresado y sacado, borré el caché del navegador. ¿Qué más debo hacer para que los valores predeterminados funcionen? – ahnbizcad

0
<default> 
    <catalog><!-- tag of the system.xml section --> 
     <frontend><!-- tag of the system.xml group --> 
      <name_of_your_field>4</name_of_your_field><!-- tag of the system.xml field --> 
     </frontend> 
    </catalog> 
</default> 
Cuestiones relacionadas