I always have to go digging to remember how to tap into Magento's events, so I'm writing this down, as much for my benefit as everyone else!

In the example below, I'm creating an extension that notifies the Magento admin on a customer's account creation.

Step 1: Create Extension

<?xml version=""1.0"" ?>
                <Mage_Customer />

<!-- /app/code/etc/modules/Birnie_CustomerCreateNotify.xml -->

Step 2: Find the Event

Using either Alan Storm's CommerceBug or this nice event cheat sheet, determine the event you'd like to observe. In my case it's customer_register_success.

It is also important to check out what is actually being passed with the observer object. In this case, I looked to the Customer Account controller and found the following:

        array('account_controller' => $this, 'customer' => $customer)

This will allow us to get the customer that registered by calling:


Step 3: Create the extension files

Create the following directories/files:

  • /app/code/local/Birnie/CustomerCreateNotify/etc/config.xml
  • /app/code/local/Birnie/CustomerCreateNotify/Model/Observer.php

Step 4: Populate extension's config.xml

  • customer_register_success refers to the event
  • class tells the class (and location) of the observer file
  • method refers to the actual method in the file to which the observer object will be passed.

Step 5: Create the Observer Model file

class Birnie_CustomerCreateNotify_Model_Observer
    public function notifyAdmin($observer)

Step 6: Clear Cache

Clear your cache and try to create an account; if all went well (and the account creation was successful), should be interrupted by a rude ""Worked"" message.

Blog Logo

Phil Birnie



Phil Birnie

Full Stack Web Developer from Columbus, Ohio

Back to Overview