How to Create Magento Extension from Scratch

create extension magento

Image credit:

create magento extension from scratchTons of Magento extensions are available for your use. But not all or even, for example, the best WordPress photo gallery plugin can qualify on your requirements as your e-commerce solutions need better modules to suffice your standards. In order to maintain your website running, creating an extension Magento is your best choice. In this tutorial, we will help you create Magento extension from scratch. If you will have troubles with creating Magento extension then you probably should hire WordPress developer.

Let us assume that you have already installed the Magento. Below are the steps to take to successfully create Magento extension:

  • Disable the cache

In order to avoid wondering why the latest Magento update is not loading and to successfully launch your Magento, make sure to disable to cache following below steps:

  • Go to Admin Panel
  • Select System
  • Find Cache Management
  • Click Select All
  • Under Actions, select disable
  • Then click Submit
  • Structuring the Directory

Open your preferred HTML editor and add new files and directories by navigating the app/code/local.Create and structure your directories to start building your extension. These are case sensitive so ensure to capitalize only when necessary.

  • Configuring the module

Configure your extension. It is found inside the module directory and named as etc. Create it along with your new XML file. The XML file provides Magento the location, version number, and events needed in configuring the extension.

  • Activating module

To activate your new Magento extension, creta e anew XML file in app/etc/modules to inform your Magento installation that you have new extensions available for activation. Name it with anything you want. Magento is interested on the content of your XML files and not on its file name. But if possible, we recommend that you use the same name for your file and module.

  • Enable your module

Check if your new Magento extensions has successfully configured. In order to access this, follow below steps:

  • Go to Magento Admin Panel
  • Go to system
  • Click on configuration
  • Select Advanced, and
  • Check the Disable Modules Output listing

You should see your extension listed as enabled. If you don’t see it enabled, something is wrong. Go back to the previous steps to discover the cause of error. Usually, new developers fall into trap of not disabling their cache, which is the primary step in creating a Magento extension from scratch.

  • Define the event observer

To extend your Magento’s functionality, define the event observers. This is one of the cleanest and powerful ways to extend your extension’s functionality without overriding or re-writing the classes or core methods. Define your config.xml.

  • Configure the model’s directory

Update the config.xml to tell Magento where to find your new models.

  • Create an observer model

Create a PHP file in the app/code/local/SmashingMagazine/LogProductUpdate/Model/Observer.php to instantiate the model.

  • Try your new extension

Now that the new Magento extension is done and completed, try and check it out. Follow below instructions:

  • Login to Magento Admin Panel
  • Update your catalog product
  • Check the var/log to see if the product-updates.log is already populated.

If the directory doesn’t exist, make sure that your permissions allow Magento to encode in the directory. Enable this by:

  • Going to Admin Panel
  • Check on the System
  • Click on the Configuration
  • Select Developer
  • Go to Log Settings
  • And set it to Enabled

Learn how to create Magento extension with the help of our tutorial today!