70 likes | 207 Views
The article will help you to understand how magento module works and to make your magento web development project successful. If you have any questions let us know in the comments section.
E N D
The Basics of Creating a Magento Module A lot of Magento community provides a variety of feature rich modules (free or paid).Together with the magento functionality, it allows you to solve a lot of tasks without programming skills. But what if they don’t work as you want them to? So it’s better to create your own module from scratch and understand the Magento architecture as well. Creating a custom magento module is a core part of any magento project. Because at any point, you may need to integrate your own functionality in your existing magento project. This article will cover a number of interesting topic : The app/code directories The structure and creation of a Magento module Event observers Before we begin install Magento, either locally or on a development server
DISABLE THE CACHE DISABLE THE CACHE You can do this by going to Admin Panel > System > Cache Management > Select All > Actions: Disable > Submit. The app/code Directory The app/code Directory app/code directory is split into three areas: core, community and local. CORE The app/code/core directory contains all of the functionality regarding products, categories, customers, payments, etc. COMMUNITY app/code/community contain modules that have been provided by third parties LOCAL An empty app/code/local directory. Here we can add modules for our magento installation. MODULE NAMESPACE MODULE NAMESPACE Create is a “namespace. Create the directory app/code/local/iMediadesigns
MODULE NAME MODULE NAME The module we are creating will write log entries each time a product is saved, Create the directoryapp/code/local/iMediadesigns/LogProductUpdate. Configuring Our Module Configuring Our Module Create a simple config.xml file <?xml version="1.0" encoding="UTF-8"?> <!-- The root node for Magento module configuration --> <config> <!-- The module's node contains basic information about each Magento module --> <modules> <!-- This must exactly match the namespace and module's folder names, with directory separators replaced by underscores
--> <iMediadesigns_LogProductUpdate> <!-- The version of our module, starting at 0.0.1 --> <version>0.0.1</version> </iMediadesigns_LogProductUpdate> </modules> </config> Activating Our Module Activating Our Module Let’s createapp/etc/modules/iMediadesigns_LogProductUpdate.xml with the following content: <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <iMediadesigns_LogProductUpdate> <!-- Whether our module is active: true or false --> <active>true</active> <!-- Which code pool to use: core, community or local --> <codePool>local</codePool> </iMediadesigns_LogProductUpdate>
</modules> </config> Is The Module Enabled? Is The Module Enabled? Navigate to System > Configuration > Advanced > Advanced and view the “Disable Modules Output” listing, we should see our iMediadesigns_LogProductUpdate module listed as enabled. Configuring Our Model’s Directory Configuring Our Model’s Directory We need to inform Magento where to find models in our module by updating config.xml <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <iMediadesigns_LogProductUpdate> <version>0.0.1</version> </iMediadesigns_LogProductUpdate> </modules> <!-- Configure our module's behavior in the global scope --> <global> <!-- Defining models --> <models>
<!-- Unique identifier in the model's node. By convention, we put the module's name in lowercase. --> <iMediadesigns_logproductupdate> <!-- The path to our models directory, with directory separators replaced by underscores -- ><class>iMediadesigns_LogProductUpdate_Model</class></iMe diadesigns_logproductupdate> </models> <events> <catalog_product_save_after> <observers> <iMediadesigns_logproductupdate><class>iMediadesigns_logpr oductupdate/observer</class> <method>logUpdate</method> <type>singleton</type> </iMediadesigns_logproductupdate> </observers>
</catalog_product_save_after> </events> </global> </config> Admin Panel > System > Configuration > Developer > Log Settings > Enabled. The article will help you to understand how magento module works and to make your magento web development project successful. If you have any questions let us know in the comments section. web development project iMediadesigns provide cost effective web design and development solutions and offers custom web in Toronto in Toronto custom website site design services design services