Magento Events Cheat Sheet Grep - Works for Any Version

If you use the Magento event / observer system for extending Magento (if you don’t you should) then you will find this little script handy for parsing out all of the events in the latest (eg Magento 1.4) version of Magento.

This is a Linux shell script so either use it on your server or if you run a decent desktop OS you should be able to run it on your desktop.

There are two parameters you need to define.

# Find all Magento Events, include file names, line numbers and the preceding 6 lines of code

#Please define these two
ABSOLUTE_PATH_TO_OUTPUT_FILE_INC_FILE_NAME= /home/joseph/magentoEvents.txt

#here is the command
find $ABSOLUTE_PATH_TO_MAGENTO_ROOT  -name "*.php" | xargs -L10 grep -n -B 6 "dispatchEvent" . > $ABSOLUTE_PATH_TO_OUTPUT_FILE_INC_FILE_NAME

# save this file as
# then do command: chmod +x
# then to run, do command: ./

Tags: magentogrepcheatsheeteventsdispatchevent