Upgrading from OpenCart 3 to OpenCart 4 is a crucial step to benefit from the most recent options, enhancements, and safety enhancements supplied by the newer model of the e-commerce platform.
This improve course of requires cautious planning and execution to make sure a easy transition whereas preserving your retailer’s information and performance.
These are the most important improve in opencart version4
- Consumer Interface and Design
- Efficiency Enhancements
- Extension Compatibility
- Safety Enhancements
- Improved search engine optimisation Options
- Upgraded Know-how Stack
- Listing construction
- Occasion-Primarily based
The main improve within the Opencart 4 is the listing construction. Model 4 now follows a unique construction in comparison with earlier variations.
What’s the distinction between model 3 & model 4?
Earlier than beginning, you will need to perceive the essential performance of Model 4. On this model, Opencart has eliminated “ocmod,” so any modifications or adjustments must be made utilizing the “occasion” system.
Opencart Model 4 makes use of namespacing for controller definition and depends on “Ajax” for dealing with all requests.

On this model 4 strategies have “void” non-return-value.

What upgrades are required to transform the model 3 extension to model 4?
To start, you will need to take a backup of your recordsdata and database. Afterward, obtain the most recent Opencart Model 4 recordsdata and configure them in the same method to the way you had beforehand configured Model 3.
Opencart model 4 introduces new adjustments, together with a modification in calling class strategies. To invoke a category technique, you will need to outline it within the following format: “extension/module/instance.save”. Notice that there’s a dot (.) separating the category and the strategy.
Let’s begin the adjustments within the add-on to make it suitable with the most recent model 4.
Be certain that you outline the “namespace” in your entire extension recordsdata with the .php extension. Subsequent, it is best to embrace an “set up.json” file within the root folder of your extension.
{ "title": "Instance Extension", "model": "1.0", "creator": "Webkul Software program Pvt. Ltd.", "hyperlink": "https://www.webkul.com", "instruction": "" }
Now let’s verify the model 4 add-on listing construction.

Let’s start the method of changing ocmod into occasions. Please guarantee that you’ve got created a technique to register all of your occasions. You need to use the next array instance as a information to register your occasions.
Occasions are labored on ” After ” & ” Earlier than ” motion calls.
Notice: If you wish to set off occasions on the entrance, you want to create your occasion file below the "catalog/controller/
” folder. Equally, for admin occasions, it is best to create the occasion file within the applicable location inside the “admin/controller/
” folder.
$eventsdata = array(); $eventsdata[] = array( 'code' => "webkulShowMenu", // occasion code // occasion set off 'set off' => "catalog/controller/account/account/earlier than", // after occasion set off motion name 'motion' => "catalog/controller/occasion/webkul|eventTrigger", 'description' => "Buyer Account Menu", // occasion description 'standing' => 1, // occasion standing [true, false] 'sort_order' => 0 // type order ); // occasion mannequin loading $this->load->mannequin('setting/occasion'); foreach($eventsdata as $occasion){ // registering occasions into DB $this->model_setting_event->addEvent($occasion); }
After registering occasions, we’re giving definitions for our occasions.
<?php /** * Extension title: Present Menu * Descrption: Utilizing this extension we are going to add menu at buyer account web page. * Writer: Webkul Software program Pvt. Ltd. * */ namespace OpencartCatalogControllerEvent; class Occasion extends OpencartSystemEngineController { /** * index * Occasion set off: catalog/mannequin/catalog/evaluation/addReview/after * @param blended $route * @param blended $information * @param blended $output * @return void */ public perform index(&$route = false, &$information = array(), &$output = array()): void { $template_buffer = $this->getTemplateBuffer($route, $output); $format = '<li class="list-inline-item"> <a href="#javascript"> <i class="fa-solid fa-cog"></i> </a> <span class="d-none d-md-inline">Webkul Settings</span> </li>'; $discover = '<div class="nav float-start">'; $exchange = '<div class="nav float-start">' . $format; $output = str_replace($discover, $exchange, $template_buffer); } /** * getTemplateBuffer * * @param blended $route * @param blended $event_template_buffer * @return string */ protected perform getTemplateBuffer($route, $event_template_buffer) { // if there already is a modified template from view/*/earlier than occasions use that one if ($event_template_buffer) { return $event_template_buffer; } } }
After finishing all steps you’ll be able to zip it and title it that ends with .ocmod.zip, then add it from the Opencart extension installer.
you’ll be able to verify us Create a module within the model 4 weblog.
In the event you want customized Opencart Growth providers then be happy to attain us and in addition discover our unique vary of Opencart Addons.