How to make an Observer in Magento ?


 Today i am going to show how to make an observers in Magento. 

In this module we are going to make _load_after event to suffix something with product name in front-end area.In same way you can make any observer.

So Lets start. 

2. Create Activation/deactivation File.

<?xml version="1.0"?>
  
    
      true
      local
    
  

2. Create configuration File.

<?xml version="1.0"?>

    
  
   
    Smartwin_Objer_Model
   
  
    
  
   
    
     
      
       Smartwin_Objer/Observer
       CatalogProductLoadAfter
      
     
    
   
  

3. Create Activation/deactivation File
<?php
/*  app/code/local/Smartwin/Objer/etc/Model/Observer.php */
class Smartwin_Objer_Model_Observer
{
 public function CatalogProductLoadAfter(Varien_Event_Observer $observer)
 {
/*   Customize code here    */
  $product = $observer->getProduct();
  $name = $product->setName($product->getName().' This is Cool!!!');
  
 }
}
?>

No comments:

Post a Comment