Today we will learn how to use event in opencart version 2.2.x.x. By using the Event System you can reduce the Ocmod and VQmod code. The Events are trigged after and before controllers, models and on loading language or view. In Opencart 2.2.x.x. the event name has been changed.
See the representation of event in Opencart version 2.2.x.x. and before 2.2.x.x. :-
Now :
‘catalog/model/account/addCustomer/after’
Before :
‘pre.catalog.customerAfter.add’
You can see before 2.2.x.x. we can used pre/post but in 2.2.x.x. we have to use after/before and ” . ” will changed into ” / “.
Basically, If you will see Event name represents like : {app}/{route}/{position}.
{app} : App should be admin/catalog.
{route} : This is the path of file after/before this path(controller/model) you want to trigger your event.
{position} : It should be before or after.
Before Opencart version 2.2.x.x. we have to add code for trigger the registered event by using vQmod or Ocmod but In 2.2.x.x. not need to add manually this code. we will see how to triggered the registered events:
Now : you can see in system/engine/loader.php file how to trigger the event for controller,model,view and load the language for after/before position.
Before :
We have to write our Event Handler for executing some option that we want to perform through event.
In Opencart Version 2.2.x.x. It might be possible your event handler returns some output. Yes if your event returns some output that this will be used as the output of the actual controller. The controller will not even be invoked. This way you can override entire modules, or default pages like product/product.
See the file system/engine/loader.php
Be the first to comment.