config.xml Reference

Last modified by peterkokot on Fri, June 22, 2012 09:54
Source|Old Revisions  

This is an old revision of the document!


Path: app/code/(codepool)/(NameSpace)/(ModuleName)/etc/config.xml

Used to configure module. Defines all models, blocks, classes etc. for the specified module.

There is a separate config.xml file for each module. However all the files are merged together during the parsing process. This insight really helps to understand the XML structure. It is the reason that the module name is repeated as an XML element name (represented below as <(modulename)>) several times through every file - this is necessary to segregate configuration for each module. Without these elements, the configuration in these sections would be overwritten by the configuration files in other modules. For the same reason, it also means that it is really important to follow the Magento naming conventions for user-defined XML elements (such as, for example, <(modulename)_setup>).

XML Structure

  1. <config>
  2. </config>

Elements

Element Description Example
modules Used to define basic information about each module such as version number, dependencies on other modules
global
admin Used to define module’s admin routers to look for the controllers in the YourModule_controllers_Adminhtml before it looks in the Mage_Adminhtml module for all urls that begin with /admin/controller_name
adminhtml
install Page
frontend
default
stores Adminhtml
websites Adminhtml

By convention, these elements are specified as in the table above. The XML sub-structure of each element is described separately below.

modules

XML Structure

  1.     <modules>
  2.          <(NameSpace_ModuleName)>
  3.              <active>[true|false]</active>
  4.              <codePool>[core|community|local]</codePool>
  5.              <depends>
  6.                  <(AnotherNameSpace_ModuleName) />
  7.              </depends>
  8.              <version>(version_number)</version>
  9.          </(NameSpace_ModuleName)>
  10.     </modules>

Elements

Element Description
active Whether module is active (this value can be overridden in back-end)
codePool Specifies subdirectory of app/code
depends Specifies dependencies of this module on other modules
version Defines version of module for use with installation / upgrades

The elements active, codePool and depends are normally defined in the app/etc/modules/(NameSpace)_*.xml files, and the version element is normally defined in the module config.xml file.

global

XML Structure

  1.     <global>
  2.         <models>
  3.             <(modulename)>
  4.                 <class>(ClassName_Prefix)</class>
  5.                 <resourceModel>(modulename)_(resource_model_type)</resourceModel>
  6.                 <(modulename)_(resource_model_type)>
  7.                     <!-- definition -->
  8.                 </(modulename)_(resource_model_type)>
  9.                 <rewrite><!-- definition --></rewrite>
  10.             </(modulename)>
  11.         </models>
  12.         <resources>
  13.             <(modulename)_setup><!-- definition --></(modulename)_setup>
  14.             <(modulename)_read><!-- definition --></(modulename)_read>
  15.             <(modulename)_write><!-- definition --></(modulename)_write>
  16.         </resources>
  17.         <blocks>
  18.             <(modulename)>
  19.                 <class>(ClassName_Prefix)</class>
  20.             </(modulename)>
  21.         </blocks>
  22.         <helpers>
  23.             <(modulename)>
  24.                 <class>(ClassName_Prefix)</class>
  25.             </(modulename)>
  26.         </helpers>
  27.         <fieldsets>
  28.             <(page_handle?)>
  29.                 <(field_name)>?</(field_name)>
  30.             </(page_handle?)>
  31.         </fieldsets>
  32.         <template>
  33.             <email>
  34.                 <(email_template_name)
  35.                     module="(modulename)"
  36.                     translate="[label][,description]"
  37.                     >
  38.                     <!-- definition -->
  39.                 <(/email_template_name)>
  40.             </email>
  41.         </template>
  42.         <events>
  43.             <(event_name)>
  44.                 <observers><!-- observers --></observers>
  45.             </(event_name)>
  46.         </events>
  47.         <eav_attributes><!-- definition --></eav_attributes>
  48.         <(modulename)><!-- custom config variables --></(modulename)>
  49.     </global>

Elements

Element Description
models
resources
blocks
helpers
fieldsets
template
events
eav_attributes
(modulename) Custom config variables

admin

XML Structure

  1.     <admin>
  2.         <attributes>
  3.             <(attribute_name) />
  4.         <attributes>
  5.         <fieldsets><!-- definition --></fieldsets>
  6.         <routers>
  7.             <(modulename)>
  8.                 <use>[standard|admin|default]</use>
  9.                 <args>
  10.                     <module>(NameSpace_ModuleName)</module>
  11.                     <frontName>(frontname)</frontName>
  12.                 </args>
  13.             </(modulename)>
  14.             <!-- or -->
  15.             <(modulename)>
  16.                 <args>
  17.                     <modules>
  18.                         <(NameSpace_ModuleName)
  19.                             before="(AnotherNameSpace_ModuleName)"
  20.                             >
  21.                             (New_ClassName)
  22.                         <(NameSpace_ModuleName)
  23.                 </args>
  24.             </(modulename)>
  25.         </routers>
  26.     </admin>

Elements

Element Description
attributes
fieldsets
routers

adminhtml

XML Structure

  1.     <adminhtml>
  2.         <events>
  3.             <(event_name)>
  4.                 <observers><!-- observers --></observers>
  5.             </(event_name)>
  6.         </events>
  7.         <global_search>
  8.             <products>
  9.                 <class>(modulename)/search_catalog</class>
  10.                 <acl>catalog</acl>
  11.             </products>
  12.             <customers>
  13.                 <class>adminhtml/search_customer</class>
  14.                 <acl>customer</acl>
  15.             </customers>
  16.             <sales>
  17.                 <class>adminhtml/search_order</class>
  18.                 <acl>sales</acl>
  19.             </sales>
  20.         </global_search>
  21.         <translate>
  22.             <modules>
  23.                 <(NameSpace_ModuleName)>
  24.                     <files>
  25.                         <default>(name_of_translation_file.csv)</default>
  26.                     </files>
  27.                 </(NameSpace_ModuleName)>
  28.             </modules>
  29.         </translate>
  30.         <layout>
  31.             <updates>
  32.                 <(modulename)>
  33.                     <file>(name_of_layout_file.xml)</file>
  34.                 </(modulename)>
  35.             </updates>
  36.         </layout>
  37.         <(modulename)><!-- custom config variables --></(modulename)>
  38.     </adminhtml>

Elements

Element Description
events
global_search
translate
layout
(modulename) Custom config variables

install

XML Structure

frontend

XML Structure

  1.     <frontend>
  2.         <secure_url>
  3.             <(page_handle)>/relative/url</page_handle>
  4.         </secure_url>
  5.         <events>
  6.             <(event_name)>
  7.                 <observers><!-- observers --></observers>
  8.             </(event_name)>
  9.         </events>
  10.         <routers>
  11.             <(modulename)>
  12.                 <use>[standard|admin|default]</use>
  13.                 <args>
  14.                     <module>(NameSpace_ModuleName)</module>
  15.                     <frontName>(frontname)</frontName>
  16.                 </args>
  17.             </(modulename)>
  18.         </routers>
  19.         <translate>
  20.             <modules>
  21.                 <(NameSpace_ModuleName)>
  22.                     <files>
  23.                         <default>(name_of_translation_file.csv)</default>
  24.                     </files>
  25.                 </(NameSpace_ModuleName)>
  26.             </modules>
  27.         </translate>
  28.         <layout>
  29.             <updates>
  30.                 <(modulename)>
  31.                     <file>(name_of_layout_file.xml)</
  32.                 </(modulename)>
  33.             </updates>
  34.         </layout>
  35.     </frontend>

Elements

Element Description
secure_url
events
routers
translate
layout

default

XML Structure

stores

XML Structure

websites

XML Structure




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs