Reading list Switch to dark mode

    Events In Opencart 2.2.x.x. Version

    Updated 19 April 2016

    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’

    Screenshot_17

    Start your headless eCommerce
    now.
    Find out More

    Before :

    ‘pre.catalog.customerAfter.add’

    Screenshot_16

    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.

    Screenshot_20

    Before :

    Screenshot_18

     

    We have to write our Event Handler for executing some option that we want to perform through event.

    Screenshot_22

    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

    Screenshot_23

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home