config.xml Reference

Last modified by houtsnip on Fri, June 25, 2010 10:09
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>).

Structure

  1. <config>
  2.     <modules>
  3.         <(NameSpace_ModuleName)></(NameSpace_ModuleName)>
  4.     </modules>
  5.     <global>
  6.         <models></models>
  7.         <resources></resources>
  8.         <blocks></blocks>
  9.         <helpers></helpers>
  10.         <fieldsets></fieldsets>
  11.         <template></template>
  12.         <events></events>
  13.         <eav_attributes></eav_attributes>
  14.         <(modulename)><!-- custom config variables --></(modulename)>
  15.     </global>
  16.     <admin>
  17.         <attributes></attributes>
  18.         <routers></routers>
  19.         <fieldsets></fieldsets>
  20.     </admin>
  21.     <adminhtml>
  22.         <events></events>
  23.         <global_search></global_search>
  24.         <translate></translate>
  25.         <layout></layout>
  26.         <(modulename)><!-- custom config variables --></(modulename)>
  27.     </adminhtml>
  28.     <frontend>
  29.         <routers></routers>
  30.         <events></events>
  31.         <translate></translate>
  32.         <layout></layout>
  33.     </frontend>
  34.     <default>
  35.         <(modulename)><!-- custom config variables --></(modulename)>
  36.     </default>
  37.     <stores>
  38.         <admin></admin>
  39.     </stores>
  40.     <websites>
  41.         <admin></admin>
  42.     </websites>
  43. </config>

Specification

Element Description
config Root element

Child elements

Element Description Example
modules Used to define basic information about each module such as version number, dependencies on other modules
global
adminhtml
admin
frontend
default
stores Adminhtml
websites Adminhtml

modules

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>
Specification
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
module_config.xml#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

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)><!-- definition --></(modulename)>
  49.     </global>

adminhtml

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.                 <use>[standard|admin|default]</use>
  17.                 <args>
  18.                     <modules>
  19.                         <(NameSpace_ModuleName)
  20.                             before="(AnotherNameSpace_ModuleName)"
  21.                             >
  22.                             (New_ClassName)
  23.                         <(NameSpace_ModuleName)
  24.                 </args>
  25.             </(modulename)>
  26.         </routers>
  27.     </admin>

adminhtml

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>

frontend

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>

default




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs