Create an observer Magento

Here this observer will display an additional message whenever a product is added to the cart.

Here the name space is PHPCodez

1) Change the directory to the root of magento installation

2) vi app/etc/modules/PHPCodez_Checkout.xml

3) Paste here the below given code

<?xml version=”1.0″?>









4) mkdir app/code/local/ (Run this command if local directory is not created )

5) mkdir app/code/local/PHPCodez

6) mkdir app/code/local/PHPCodez/Checkout

7) mkdir app/code/local/PHPCodez/Checkout/etc

8) mkdir app/code/local/PHPCodez/Checkout/Model

9) vi app/code/local/PHPCodez/Checkout/etc/config.xml

10) Paste here the below given code

<?xml version=”1.0″?>





















11) vi app/code/local/PHPCodez/Checkout/Model/Observer.php

12)  Paste here the below given code


       class PHPCodez_Checkout_Model_Observer {

               public function CustomerEdit($observer) {

                       echo Mage::getSingleton(‘checkout/session’)->addSuccess(“Inside Obserevr”);




13) Clear the cache and check it by adding the product to cart .

Download source file

Hope it would be helpful