Store-Frontend: What is the first event that can be observed?
-
12-12-2019 - |
Question
With a current, vanilla Magento 1.9.1 (CE) or 1.14.1/1.14.2 (EE) what is the first event that can be observed?
- for the frontend (via
/index.php
; when the installer did run already) - for the frontend, when the installer did not yet run (if it makes a difference)
- for the adminhtml
- in cron
- in webservice API 1
- in webservice API 2
(this question might be looking for pure facts, but more interesting in the scope of Magento 1 is how to find these events in code)
In process of finding out more, I've collect some web-resources:
- What's the earliest event Magento dispatches? (Q&A Jun 2011)
- Magento Startup Events (Sep 2012; by Alan Storm)
- What is the first event fired in Magento? - (Apr 2014; by E. Schrade)
Solution
It is possible to observe these events yourself as follows:
/app/Mage.php modify the dispatchEvent()
function as below:
/**
* Dispatch event
*
* Calls all observer callbacks registered for this event
* and multiple observers matching event name pattern
*
* @param string $name
* @param array $data
* @return Mage_Core_Model_App
*/
public static function dispatchEvent($name, array $data = array())
{
Mage::log($name, null, 'events.log', true); //add this line
Varien_Profiler::start('DISPATCH EVENT:'.$name);
$result = self::app()->dispatchEvent($name, $data);
Varien_Profiler::stop('DISPATCH EVENT:'.$name);
return $result;
}
Now when you run the page, you'll notice that /var/log/events.log
logs every event, in order, when loading whichever page you're interested in observing.
Make sure that this is performed in a staging environment where you are the only person using the site, to ensure you're logging the correct events.
Clean out the log file after observing each page individually so that the first event logged is always the first event fired.