Magento – Magento 2: How to track list of event generated in checkout order placed

checkoutevent-observermagento2place-order

How to get list of all events are executed where magento place order in checkout page?
Get the list of all events step by steps.
Any tools we can observe which event fire first and which events are used at that steps?

Best Answer

Here is how I would do it.

You need to create a module and a plugin for that.

In app/code/Vendor/Module/etc/di.xml you need the following:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <type name="Magento\Framework\Event\ManagerInterface">
        <plugin name="list_dispatched_event" type="Vendor\Module\Plugin\ListDispatchedEvents" sortOrder="10" disabled="false"/>
    </type>
</config>

Then in your app/code/Vendor/Module/Plugin/ListDispatchedEvents.php file:

<?php

namespace Vendor\Module\Plugin;
class ListDispatchedEvents
{
    public function beforeDispatch($subject, $eventName, array $data = [])
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info($eventName);
    }

}

Then I suggest you disable that module until you reach the page where you can click the Place Order button. Re enable module, click the button, disable the module once the the page has redirected you to the success page and check the var/log/test.log file.

Related Topic