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

Introduction


In the Magento application, there are a lot of events that happen when visitors are browsing through your website. The visitor can add something to the cart, log in, create an order, and do a lot more.

Magento has an event system that fires events when some actions happens in your shop. With a configuration, it is possible to execute some code when an event occurs. It's like hooking into a click event in JavaScript.

The observer design pattern is used to implement the event handling system. When an event is triggered, Magento looks for event observers that hook into that event and execute the right method that is configured for that event handler.

Another similar system in Magento is a cronjob. In the configuration, you can create a cronjob that will be executed on a specific timestamp. When it is the right time, Magento will execute the code that is configured for that cronjob.

In this chapter, we will explore the possibilities of using these two systems (Event handlers and cronjobs...