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?
2 Answers
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.
All events go through Magento\Framework\Event\Manager::dispatch
.
you can add a logger inside that method or build a before
plugin to log the $eventName
variable passed to the method. Then go through the checkout process and see what's logged.
-
-
1@RaphaelatDigitalPianism Not exactly, but pretty close. I might think you are copying my answers :D– Marius ♦May 31, 2016 at 7:11
-
I time travel in the future to steal your answers, didn't I tell you ? May 31, 2016 at 7:12
-
Actually I answered 4 minutes faster. So I guess I traveled in the past to post before you :)– Marius ♦May 31, 2016 at 7:13
-
Dammit you're right, I guess you tricked me, you're the one stealing my answers ^^ May 31, 2016 at 7:15