Opencart tutorial – how to code single and multi-instance module?

In this Opencart tutorial, we are showing you the difference between the coding structure of a single instance Opencart module and Opencart multi-instance module both in the admin section and the catalog section.

Single Instance Opencart moduleMulti-Instance Opencart module
After installation, it will create only one moduleAfter installation, it can create many modules as many as needed
Single vs Multi instance opencart module
Example of core available only one instance Opencart module are: Account module, Category module, Information module, etcExample of core available multi-instance Opencart modules is: Banner module, Bestsellers module, Carousel module, Featured module, latest module, a slideshow module, special module, etc.
Admin section code change
$this->model_setting_setting->editSetting(‘module_login’, $this->request->post);if (!isset($this->request->get[‘module_id’])) {
his->model_setting_module->addModule(‘bestseller’, $this->request->post);
} else {
$this->model_setting_module->editModule($this->request->get[‘module_id’], $this->request->post);
Name of the form field should start with the extension initials, for the module, it is like name=”module_*****”, for the shipping extension, it is like name=”shipping_***”, for payment extension name=”payment_***” etc.Name of the form field can be any
Data are saved in oc_setting database tableData are saved in oc_module database table
Catalog section code change
The code difference in the controller is at the index method.
public function index() {
public function index($setting) {
In oc_layout database table, the cod will be stored in the code column
In oc_layout database table, the code dot module id is stored in the code column
Opencart database layout
Some other extra codes for multi-instance opencart module are:
– Form action link need to be if-else as per module id
– Last Breadcrumbs link need to link to module id link
Extra code:
if (isset($this->request->get[‘module_id’]) && ($this->request->server[‘REQUEST_METHOD’] != ‘POST’)) {
    $module_info = $this->model_setting_module->getModule($this->request->get[‘module_id’]);

These are the differences between a single instance module and a multi-instance module of Opencart. If you are looking for Opencart module development tutorial then here are the two videos and four posts that will help you to understand the code and flow of Opencart modules.

Please let us know if you have any questions or suggestions, please subscribe to our YouTube Channel for Opencart video tutorials and you can see more at Opencart tutorial category. You can also find us on Twitter and Facebook. Enjoy!

Previous articleOpencart 3 module development tutorial, multi-instance testimonial free
Next articleReports, Who’s online, and Statistics reports in Opencart 3



Please enter your comment!
Please enter your name here