Create new module in Magento – As you know, Magento has its own modules in /app/core/ directory. In this tutorial, we’re going to create a simple module which is necessary to use in other tutorials.
To make Magento recognize your module, you need to create at least following directories and files:
/app/etc/modules/YourVendor_YourModule.xml
/app/code/local/YourVendor/YourModule/etc/config.xml
/app/code/local/YourVendor/YourModule/Helper/Data.php
Let’s do it step by step:
Contents
1. Create file /app/etc/modules/YourVendor_YourModule.xml
with content:
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0"?> <config> <modules> <YourVendor_YourModule> <active>true</active> <codePool>local</codePool> </YourVendor_YourModule> </modules> </config> |
This file make Magento know about your module name and code pool ( which is ‘YourVendor_YourModule’ and ‘local’)
2. Create your module config file /app/code/local/YourVendor/YourModule/etc/config.xml
with content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?xml version="1.0"?> <config> <modules> <YourVendor_YourModule> <version>1.0.0</version> </YourVendor_YourModule> </modules> <frontend> <routers> <yourmodule> <use>standard</use> <args> <module>YourVendor_YourModule</module> <frontName>yourmodule</frontName> </args> </yourmodule> </routers> </frontend> <admin> <routers> <adminhtml> <args> <modules> <YourVendor_YourModule before="Mage_Adminhtml">YourVendor_YourModule_Adminhtml</YourVendor_YourModule> </modules> </args> </adminhtml> </routers> </admin> <global> <helpers> <yourmodule> <class>YourVendor_YourModule_Helper</class> </yourmodule> </helpers> </global> </config> |
3. Create your module helper file /app/code/local/YourVendor/YourModule/Helper/Data.php
with content:
1 2 3 4 5 6 |
<?php class YourVendor_YourModule_Helper_Data extends Mage_Core_Helper_Abstract { } |
After creating those files, go to your backend -> System -> Cache Management, refresh all cache types and flush cache storage also.
At last, to check if Magento recognized your module, go to your backend -> System -> Configuration -> Advanced -> Disable Modules Output, you can see your module with name ‘YourVendor_YourModule‘ has been listed.
If you got any problem when create new module in Magento, please leave a comment or contact us.
Create a custom product type in Magento - Magento and Javascript tutorials
[…] In this tutorial, we will show you how to create a custom product type in Magento. If you don’t have your own module, please create a simple one following this post. […]
Add custom product attribute in Magento - Magento and Javascript tutorials
[…] Add custom product attribute in Magento – In Magento, product is an EAV Model so to add a custom product attribute we need to create an EAV attribute. Before starting, make sure that you already prepared your own module. If you haven’t, you can create a simple module following this post. […]
Add custom product attribute in Magento - Metagento Blog - Magento and Magento 2 tutorials
[…] Add custom product attribute in Magento – In Magento, product is an EAV Model so to add a custom product attribute we need to create an EAV attribute. Before starting, make sure that you already prepared your own module. If you haven’t, you can create a simple module following this post. […]
Create custom product type in Magento -METAGENTO - Magento Tutorials
[…] In this tutorial, we will show you how to create a custom product type in Magento. If you don’t have your own module, please create a simple one following this post. […]