Magento developing guide(basic)
On 06/01/2012 MagentoIn order to customize magento code first step is to learn how to make a module. First of all, we're going to define our module within Magento. For this, we need to create a file called Namespace_MyModule.xml within the Magento folder app/etc/modules with the following contents:
<!--?xml version="1.0"?--> <config> <modules> <namespace_mymodule> <active>true</active> <codepool>local</codepool> </namespace_mymodule> </modules> </config>
Next, we are going to create the module necessary folders. Create the following folder-structure within the app/code/local directory: * Namespace * Namespace/MyModule * Namespace/MyModule/etc * Namespace/MyModule/Helper Sometimes, a module also can contains extra folders like Block, Model and controllers, but we are going to skip that within this example.
class Namespace_MyModule_Helper_Data extends Mage_Core_Helper_Abstract { public function test() { return 'Hello'; } }
We are creating a configuration-file Namespace/MyModule/etc/config.xml which contains XML-code that tell magento info about structure of our module and you might not yet understand.
<!--?xml version="1.0"?--> <config> <modules> <namespace_mymodule> <version>0.0.1</version> </namespace_mymodule> </modules> <global> <blocks> <mymodule> <class>Namespace_MyModule_Block</class> </mymodule> </blocks> <helpers> <mymodule> <class>Namespace_MyModule_Helper</class> </mymodule> </helpers> </global> </config>
Now our custom module is ready to be used. For example if we want to use helper function, in other files from magento we simply call in this way:
Mage::helper('mymodule/data')->test();