2

I wanna use customer_logout event to un-register data from registry.

Can anybody help?

1
  • what you mean by un-register?
    – Amit Bera
    Jun 29, 2015 at 12:41

2 Answers 2

4

You can use customer_logout event to do that below is sample code write the code in your config.xml

   <events>
   <customer_logout>
        <observers>
            <Namespace_Module_Model_Observer>
                <type>singleton</type>
                <class>Namespace_Module_Model_Observer</class>
                <method>CustomerLogout</method>
            </Namespace_Module_Model_Observer>
        </observers>
    </customer_logout>
   </events>
2
  • Thanks Ali, I did same but the method was not getting called.I checked by adding the code in both global and front end sections.
    – Phani Bob
    Jun 29, 2015 at 13:08
  • @PhaniBob i use the event and this worked for me can you write some code of your config.xml that how you use the event Jun 30, 2015 at 12:31
2

First you need study about magento event/observer from

Here an example :

   <global><!-- here global is define the where are you want to fire event. If we make it frontend then it will fire in frontend
    if Fire admin area then it should be adminhtml

 Value: global/adminhtml/frontend
    -->
        <events>
          <customer_logout> <!-- identifier of the event we want to catch -->
            <observers>
              <customer_logout_handler> <!-- identifier of the event handler -->
                <type>model</type> <!-- class method call type; valid are model, object and singleton -->
                <class>modulename/observer</class> <!-- observers class alias -->
                <method>FireAndfuncyion</method>  <!-- observer's method to be called -->
              </customer_logout_handler>
            </observers>
          </customer_logout>
        </events>
      </global>

when magento is fire an event then it send some parameters to Observer.Using this parameter implement your operation.

Whenever magento fire customer_logout event then it send customer data to Observer.

 Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) );

thus we can use this data.

On observer you can get this parameters value data

<?php
class ModuleNameSpace_ModuleName_Model_Observer
{

    public function FireAndfuncyion(Varien_Event_Observer $observer)
    {
           // Mage::dispatchEvent('customer_logout', array('customer' => $this->getCustomer()) );
        $customer = $observer->getEvent()->getCustomer();

    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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