-1

I can't get an observer working, I'm using Magento of 1.9.1.0.

My namespace: pan

My module: Registration

app/etc/modules/pan_Registration.xml:

pan_Registration

app/code/local/TM/ProductConditions/etc/config.xml:

enter image description here

Observer.php :

<?php

class pan_Registration_Model_Observer 
 {


    public function customerRegisterSuccess($observer) {
        echo "kjdsnfkjsdfknsd";
        $event = $observer->getEvent();
        $cid = $event->getCustomer();
        echo "kjdsnfkjsdfknsd";
    echo $cid;
    exit;       
   }
}
?>
  • observer.php : <?php class pan_Registration_Model_Observer { public function customerRegisterSuccess($observer) { echo "kjdsnfkjsdfknsd"; $event = $observer->getEvent(); $cid = $event->getCustomer(); echo "kjdsnfkjsdfknsd"; echo $cid; exit; } } ?> – Abdul Aziz Mar 2 '16 at 13:12
4

The module cannot be loaded. In app/etc/modules/pan_Registration.xml you specify that the module is found in app/code/local/pan/Registration, but you put it in app/code/local/TM/ProductConditions.

Additionally a lower case vendor name (pan) is against the conventions. I'm actually not sure if it really works, so you should consider changing pan_Registration to Pan_Registration in the <modules> element of both XML files, and move the module files to app/code/local/Pan/Registration

1

Your namespace: pan

First character should be a capital letter like Pan

app/etc/modules/Pan_Registration.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Pan_Registration>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Pan_Registration>
  </modules>
</config>

app/code/local/Pan/Registration/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Pan_Registration>
      <version>0.1.0</version>
    </Pan_Registration>
  </modules>
  <global>    
    <models>
      <registration>
        <class>Pan_Registration_Model</class>
        <resourceModel>registration_mysql4</resourceModel>
      </registration>
    </models>
    <events>
      <customer_register_success>
        <observers>
          <customer_register_success_handler>
            <type>model</type>
            <class>registration/observer</class>
            <method>customerRegisterSuccess</method>
          </customer_register_success_handler>
        </observers>
      </customer_register_success>
    </events>
  </global>
</config> 

app/code/local/Pan/Registration/Model/Observer.php

<?php
class Pan_Registration_Model_Observer
{

            public function customerRegisterSuccess(Varien_Event_Observer $observer)
            {
                //Your code
            }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.