Idea Transcript
Envato Elements
How-To Tutorials
Courses
eBooks
Envato Studio
Community
Pricing
Forum
Help
Subscribe
Sign In
Search Envato Tuts+
Advertisement
CODE > MAGENTO
Magento Custom Module Development by Chirag Dodia 14 Aug 2014
Magento
PHP
FEED
Difficulty: Beginner Length: Medium Languages: English
eCommerce
LIKE
FO LLO W
FO LLO W
Weekly email summary
Web Development
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Magento custom module development is a core part of any Magento development or Magento project, because at any stage you may want to integrate your own functionality/module in your existing Magento project.
Email Address
In this series, I am going to cover the details of Magento custom module development.
Update me weekly
If you want to go further with your Magento development, check out the wide range of useful Magento extensions on Envato Market.
Advertisement
Download Attachment
Translations Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too! Translate this post
Magento extensions on Envato Market
Powered by
Throughout this series, I'm referring Magento Community Edition 1.7, though custom module structures are the same in all versions of Magento. Before going we're going to start actual module development, let's quickly understand the basic structure of Magento. Whenever you install a fresh Magento, you will notice the following Magento directory structure:
Advertisement
WATCH ANY COURSE NOW Subscribe to Access
Introduction to Magento MVC Structure Like any other major frameworks such as Joomla, CakePHP, CodeIgniter, etc., Magento also follows the MVC-based architecture though this is little bit different than core PHP MVC architecture. Here, I'll explain the difference in Magento architecture by comparing it with simple PHP MVC architecture.
PHP MVC architecture In the typical MVC pattern, the flow of the application is something like this: 1. There is main entry point - index.php - from where the entire app routing mechanism is determined. 2. Based on this routing mechanism and requested URL pattern, the app will call the appropriate controller. 3. The controller then calls the appropriate views. 4. Finally, the view files collect the ?> true local
This file will tell Magento about the location of our module. In the active tag, we have specified true to enable our module. If everything is correct thus far, then you will find your module in the Magento Admin Panel > System > Configuration > Advanced > Advanced > Disable Modules Output list. From here you can enable and disable your module.
Getting Started: Development Next we will create our module configuration file. This file will tell Magento all about our module. This includes how many files our module contains, what type of files (models, helpers, ?> 0.1.0 standard Chiragdodia_Mymodule mymodule
Let's go through line by line to understand each tag. Here, the first tag is
that contains the name and version of our module. The version
number is very important when it comes to updating your module update your module. The tag will tell Magento about the controller dispatched. Inside the tag, we have defined that tells Magento how to access our controllers via the routing mechanism. In the tag, we have defined module name in tag and frontend name in . By using a frontend name, we can access our module in frontend like yoursitename.com/index.php/mymodule/index . By calling yoursitename.com/index.php/mymodule or yoursitename.com/index.php/mymodule/index Magento will look for index action of your module's controller file. As such, we need to create our controller file. Go to app/code/local/Chiragdodia/Mymodule/controllers and create file IndexController.php with following content. Note that each file's name and class names are case sensitive in Magento It's very important that you are taking care in naming your work when creating files and classes. 1 2 3 4 5 6 7 8