5

I am in the process of writing some in-house documentation that goes a bit beyond the "hello world" examples that populate the internet and would like to start a complete reference wiki on some of the "copy and paste" parts that most tutorials gloss over.

Thus far the most complete reference that I have found is located at http://www.magentocommerce.com/wiki/5_-_modules_and_development/reference/module_config.xml but it is only 25% complete!

My question is plain and simple: where can I find more authoritative documentation on module configuration?

  • Thanks for the links. Now the available "documentation" is up to 28%. I sincerely hope the internet has more light to shed on this topic...otherwise I'm going to be in for a deep dive into alien source code. – Luke A. Leber May 17 '15 at 23:44
  • Heh, not sure if it was produced by the Greys or Reptiloids, but I like the idea that Magento was produced by aliens. Alan Storm and Ben Marks are two of the go-to guys who've been pulled into the gravitational pull of Magento and can help make it less alien. – Fiasco Labs May 18 '15 at 5:02
  • One of the reasons it's not complete is because there is no definitive reference to be made. A lot of parts are dynamic. In fact, it's possible to write a checkout module that allows other payment methods to specify the minimum and maximum order amount they accept, through config.xml. There are certain rules to be observed and some fix name tags, but overall structure is more important then names. Is there anything specific you are missing from the things you found on the net versus things you have seen in the wild? – Melvyn May 18 '15 at 7:47
  • 1
    The entire set of config.xmls in Mage_Core is as complete as it can get. – musicliftsme Jul 16 '15 at 14:56
13

Rico Neitzel and me gave a presentation about this topic, you can find our slides online

Configuration is needed

config.xml

We need the config.xml in the module directory to configure the whole module. Here all PHP classes are (pre-)configured and files are "linked"


explained example of a small but complete config.xml

<?xml version="1.0"?>
<config>
    <!-- Versioning: important for install scripts (setup and data) -->
    <modules>
        <Namespace_Module>
            <version>0.1.0</version>
        </Namespace_Module>
    </modules>

    <!-- Nodes for the global configuration -->
    <global>
        <models>
            <!-- this node is called class-group and is later used in Mage::getModel() -->
            <namespace_Module>
                <!-- the class-group 'namespace_module' is solved by magento to 'Namespace_Module_Model' -->
                <class>Namespace_Module_Model</class>
                <resourceModel>namespace_Module_resource</resourceModel>
            </namespace_Module>
            <!-- this node is called class-group too and is later used indirectly by Mage::getResourceModel()
            <namespace_Module_resource>
                <class>Namespace_Module_Model_Resource</class>
                <entities>
                    <!-- this node is called entity and is used to find table names -->
                    <developer>
                        <!-- the table name itself -->
                        <table>developer</table>
                    </developer>
                </entities>
            </namespace_Module_resource>
        </models>
        <blocks>
            <!-- this node is again a class-group and is used by Mage::getBlock() -->
            <namespace_Module>
                <!-- the class-group 'namespace_module' is solved by Magento to 'Namespace_Module_Block' -->
                <class>Namespace_Module_Block</class>
            </namespace_Module>
        </blocks>
        <helpers>
            <!-- hey, a class-group. This is used in Mage::helper() -->
            <namespace_Module>
                <!-- and the solution this time is: 'Namespace_Module_Helper' -->
                <class>Namespace_Module_Helper</class>
            </namespace_Module>
        </helpers>
        <resources>
            <!-- this node defines the name of the sub directory name in ./sql und ./data for the install scripts -->
            <namespace_Module_setup>
                <setup>
                    <module>Namespace_Modul</module>
                </setup>
            </namespace_Module_setup>
        </resources>
    </global>
</config>

Subnodes

in config.xml


modules

<modules>
    <{Namespace_Modul}>
        <version>

^ Modul version


global /1

<models>
    <{namespace_modul}>
        <class>
        <resourceModel>
    <{namespace_modul}_resource>
        <deprecatedNode>
        <entities>
            <{entity}>
                <table>
        <rewrite>
            <{model}>

^ How to define models, resouce models and entities


global /2

<helpers>
    <{namespace_modul}>
        <class>
        <rewrite>
            <{helper}>

<blocks>
    <{namespace_modul}>
        <class>
        <rewrite>
            <{block}>

^How to defined helpers and blocks, rewrites included


global /3

<index>
    <indexer>
        <{indexer_code}>
            <model>
            <depends>
                <{indexer_code}/>

<cache>
    <types>
        <{cache_code}>
            <label>
            <description>
            <tags>

^ How to define your own indexes and caching options


global /4

<resources>
    <{namespace_modul}_setup>
        <connection>
            <use>
        <setup>
            <module>
            <class>

<template>
    <email>
        <{email_template_code}>
            <label>
            <file>
            <type>

<page>
    <layouts>
        <{page_template_code}>
            <label>
            <template>
            <layout_handle>
            <is_default>

^ How to define your own database connection, setups inlcluding setup class, email and page templates


global /5

<events>
    <{event_name}>
        <observers>
            <{namespace_modul}>
                <type>
                    <model>
                    <class>
                    <method>

^ Event/Observer


global /6

<sales>
    <quote>
        <item>
            <product_attributes>
                <sku/>
                <type_id/>
                <name/>
                <status/>
                <visibility/>
                <price/>
                <weight/>
                <url_path/>
                <url_key/>
                …

^ How to add attributes loaded by the product collection for a quote item, DON USE PRODUCT LOAD HERE.


install

<events>
    <{event_name}>
        <observers>
            <{namespace_modul}>
                <type>
                    <model>
                    <class>
                    <method>

<translate>
    <modules>
        <{Namespace_Modul}>
            <file>
                <default>
                <others>

<layout>
    <updates>
        <{namespace_modul}>
            <file>      

^ Translation, Events and Layout files in install context


admin

<routers>
    <{routername}>
        <use>
        <args>
            <module>
            <frontName>
            <modules>
                <{Namespace_Modul}>

^Add you rown admin router


adminhtml /1

<events>
    <{event_name}>
        <observers>
            <{namespace_modul}>
                <type>
                <model>
                <class>
                <method>

<translate>
    <modules>
        <{Namespace_Modul}>
            <file>
                <default>
                <others>

^ How to add your own event/translation for the admin backend


adminhtml /2

<layout>
    <updates>
        <{namespace_modul}>
            <file>

<global_search>
    <{entity}>
        <class>
        <acl>

^ Layout files and settings added to the global search


frontend /1

<category>
    <collection>
        <attributes>
            <{category_attributecode_to_load}>

<product>
    <collection>
        <attributes>
            <{product_attributecode_to_load}>

<routers>
    <{routername}>
        <use>
        <args>
            <module>
            <frontName>
            <modules>
                <{Namespace_Modul}>

^ How to add attributes to the category and product collection ^ And routes in the frontend


frontend /2

<events>
    <{event_name}>
        <observers>
            <{namespace_modul}>
                <type>
                    <model>
                    <class>
                    <method>

<translate>
    <modules>
        <{Namespace_Modul}>
            <file>
                <default>
                <others>

<layout>
    <updates>
        <{namespace_modul}>
            <file>

^ Events, translation files and layout updates in the frontend


crontab

<crontab>
    <jobs>
        <{cronjob_identifier}>
            <schedule>
                <cron_expr>
            <run>
                <model>

^Define your own cronjob

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.