Book Image

Magento 2 Development Cookbook

Book Image

Magento 2 Development Cookbook

Overview of this book

With the challenges of growing an online business, Magento 2 is an open source e-commerce platform with innumerable functionalities that gives you the freedom to make on-the-fly decisions. It allows you to customize multiple levels of security permissions and enhance the look and feel of your website, and thus gives you a personalized experience in promoting your business.
Table of Contents (18 chapters)
Magento 2 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding event types


Working with event types is better than overwriting a function with dependency injection. When analyzing a process, it is good to think about how you can solve your problem. It is better to execute extra code instead of rewriting the standard functions of Magento.

With events, it is possible to execute code when something happens, but before we can do that, we have to know which events are available, when they are dispatched, and which parameters are available.

Getting ready

In this recipe, we will debug the events that are fired in Magento. Ensure that you have access to the command line because we will debug using the Magento log files.

How to do it...

The following steps describe how we can create a list from the dispatched events in a Magento request:

  1. Magento events are dispatched using the dispatch() method of the eventManager interface. When we want to debug this function, we have to modify the Magento\Framework\Event\Manager class. The first thing to do is to enable...