How To Create Observers | Customer logout


Again we need our own mudule. Assuming we have module with namespace Guides and module name Meta

Static and dynamic events

We can divide Magento events into static and dynamic.

Static are:

Mage::dispatchEvent('admin_session_user_login_failed', array('user_name' => $username, 'exception' => $e));

Mage::dispatchEvent('cms_page_prepare_save', array('page' => $model, 'request' => $this->getRequest()));

Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));

Mage::dispatchEvent('catalog_product_flat_prepare_columns', array('columns' => $columnsObject));

Mage::dispatchEvent('catalog_prepare_price_select', $eventArgs);

Dynamic are:

Mage::dispatchEvent($this->_eventPrefix.'_load_before', $params);

Mage::dispatchEvent($this->_eventPrefix.'_load_after', $this->_getEventData());

Mage::dispatchEvent($this->_eventPrefix.'_save_before', $this->_getEventData());

Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());


Let’s say we want to execute our code before we edit new page in Magento admin panel. When you check core files and the save method, you will see this code

Mage::dispatchEvent('cms_page_prepare_save', array('page' => $model, 'request' => $this->getRequest()));

What interest us is the name of the event: cms_page_prepare_save.

Create observer

Create file app/code/local/Guides/Meta/Model/Observer.php

we will put this code inside

echo "Im here";
class Guides_Meta_Model_Observer extends Varien_Event_Observer {
  public function __construct() {


  public function saveCmsPageObserve( $observer ) { // We chose this method name.
    $event = $observer->getEvent();
    $model = $event->getPage();
    print_r( $model->getData() );
    die( 'test' );

Register Model and Observer in module config

        <guides_meta> <!-- **Note the lowercase -->
            <guides_meta> <!-- **Note the lowercase -->
                <class>Guides_Meta_Model</class> <!-- We have to register our model first. -->
            <cms_page_prepare_save> <!-- This is the event name -->
                        <class>guides_meta/observer</class> <!-- Than we assign our class with method which will be executed when event happens **Note the lowecase letters.. -->
                    </guides_meta> <!-- **Note the lowercase -->

Now go to your admin panel.


Click on some page, edit it a click save.

Than you should see something like this.

edit page how it looks like

Lukas Stranovsky
I am the guy who made this. Sorry for typos.