Home » Uncategorized » From Beginner to Advanced in OpenCart: Module Development

From Beginner to Advanced in OpenCart: Module Development

OpenCart modules are analogous to add-ons, plugins, or extensions in other content management systems. It’s through modules that OpenCart gives us the ability to extend its functionality without having to edit the application’s files.

As with many other content management systems, it’s generally considered to be a best practice to extend functionality of the core application through the provided APIs and OpenCart is no different. Modules allow us to introduce, remove, or modify functionality of the core application that’s done in a compartmentalized and maintainable way.

OpenCart has its own Extension Market where a large number of extensions are already available. Or you can check out the wide range of OpenCart modules and extensions on Envato Market.

 

Note that OpenCart has a number of pre-build modules. As such, we’ll try to leverage those when possible when working on our own. To get started, perform the following:

  1. Create an Controller to Admin Path: admin/controller/module/helloworld.php .
  2. Create a Language File to Admin Path: admin/language/english/module/helloworld.php .
  3. Create a View to Admin Path: admin/view/template/module/helloworld.tpl .

As discussed in our previous articles, the language file contains the static text what should be displayed in our view file. For the helloworld.php language file, the following variables contain the possible text fields what we require to display in our module:

Open the “Hello World” controller file that we just created and add the class class ControllerModuleHelloworld extends Controller {} following the Class Naming Convention. Next, place the following code inside the class.

 

 

more