Book Image

Magento 2 Developer's Guide

Book Image

Magento 2 Developer's Guide

Overview of this book

Magento is one of the most exciting, flexible, and customizable e-commerce systems. It offers you an extensive suite of powerful tools for creating and managing an online store. After years of development, Magento 2 introduces itself with a strong emphasis on modularity, Web API's, automated testing and overall new technology stack platform.The long-awaited Magento 2 release introduces a whole new e-commerce platform to develop online stores. The all new Magento 2 architecture, Web APIs, and a host of other features are equally challenging to master as much as they are exciting to use. Tshis book will ease the learning curve by offering step-by-step guidance on how to extend the core functionality of your Magento 2 store. This book is your one-stop guide to build and customize a quality e-commerce website from the latest version of one of the largest, fastest growing, and most popular e-commerce platforms—Magento 2. We start off with an introduction to the fundamental concepts of Magento to give you a foundation to work from. We then move on to configure the development and basic production environment for Magento. After this, you’ll get to grips with the major concepts and conventions that are new to the Magento 2 platform. We then delve deeper to get to the core of automated deployments, persisting data, writing data fixture scripts and applying various backend and frontend modifications. As we near the end of the book, you will learn to make API calls and write automated tests. Finally, you will be guided through building a full-blown helpdesk module from scratch. By the end of this book, you will have learned a wide range of techniques to extend and customize your Magento 2 store to fit the requirements of your business.
Table of Contents (19 chapters)
Magento 2 Developer's Guide
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

The plugin sort order


Looking back, when we defined a plugin in the di.xml file, one of the attributes that we set for every plugin definition was sortOrder. It was set to 100, 200 to 300 for foggyPlugin1, foggyPlugin2 and foggyPlugin3 respectively.

The flow of the code execution for the preceding plugins is as follows:

  • Plugin1 - beforeGetAddToCartUrl

  • Plugin1 - aroundGetAddToCartUrl

  • Plugin2 - beforeGetAddToCartUrl

  • Plugin2 - aroundGetAddToCartUrl

  • Plugin3 - beforeGetAddToCartUrl

  • Plugin3 - aroundGetAddToCartUrl

  • Plugin3 - afterGetAddToCartUrl

  • Plugin2 - afterGetAddToCartUrl

  • Plugin1 - afterGetAddToCartUrl

In other words, if multiple plugins are listening to the same method, the following execution order is used:

  • The before plugin functions with the lowest sortOrder value

  • The around plugin functions with the lowest sortOrder value

  • The before plugin functions following the sortOrder value from the lowest to the highest

  • The around plugin functions following the sortOrder value from the lowest to the highest

  • The...