Our blog

 

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.

CODE:
  1. #!/bin/bash
  2. # Find all Magento Events, include file names, line numbers and the preceding 6 lines of code
  3.  
  4. #Please define these two
  5. ABSOLUTE_PATH_TO_MAGENTO_ROOT=/home/joseph/Projects/Magento/
  6. ABSOLUTE_PATH_TO_OUTPUT_FILE_INC_FILE_NAME= /home/joseph/magentoEvents.txt
  7.  
  8. #here is the command
  9. find $ABSOLUTE_PATH_TO_MAGENTO_ROOT  -name "*.php" | xargs -L10 grep -n -B 6 "dispatchEvent" .> $ABSOLUTE_PATH_TO_OUTPUT_FILE_INC_FILE_NAME
  10.  
  11. # save this file as magentoevents.sh
  12. # then do command: chmod +x magentoevents.sh
  13. # then to run, do command: ./magentoevents.sh

More Reading:

 

Leave a Reply