0

I have used the Observer event in my Custom module, but when i load the added event, it is showing below error message,

Mage Registry key "Observer" already exists.

I have checked the Compiler Mode, it is in Disable state.

I am using event, Any help will be much appreciated.

<global>
    <events>
        <sales_order_status_history_save_before>
            <observers>
                <auto_order_statua>
                    <class>Custom_Status_Model_Observer</class>
                    <method>implementOrderStatus</method>
                </auto_order_statua>
            </observers>
        </sales_order_status_history_save_before>
    </events>
</global>

Observer.php

class Custom_Status_Model_Observer
{

    public function implementOrderStatus(Varien_Event_Observer $observer)
    {
        //$order = $observer->getOrder();
        //$stateProcessing = $order::STATE_PROCESSING;
        //$state = $order->getState();
        mail('nagamaniatnaresh@gmail.com', 'test', 'test');
    }

}
  • And what code you are using inside your observer ? Is there any call to Mage::register in there ? – Prateek Nov 21 '15 at 9:04
  • I am just using mail function to check whether it was triggered. – user2520 Nov 21 '15 at 9:36
  • Well then, your module doesn't seem to be the culprit. Try removing this event and see if error still persists. – Prateek Nov 21 '15 at 9:46
  • When i removed the Event from XML it is working fine, but when i add the codes for Event, it gets started... – user2520 Nov 21 '15 at 9:50
0

In config.xml you should change name your event as(some_unique_identifier must unique)

    <events>
        <name_of_event_in_magento>
            <observers>
                <some_unique_identifier>
                    <type>singleton</type>
                    <class>Vendor_YourModule_Model_Observer</class>
                    <method>yourMethod</method>
                </some_unique_identifier>
            </observers>
        </name_of_event_in_magento>
    </events>
| improve this answer | |
  • Thanks for your Answer Paw, I have updated the code in the Question – user2520 Nov 21 '15 at 8:09
  • @Nagamani, it woking ?? – Thao Pham Nov 21 '15 at 8:14
  • No its not @Paw – user2520 Nov 21 '15 at 8:19
  • Are you add "<type>singleton</type>" in <auto_order_statua> ? – Thao Pham Nov 21 '15 at 8:42
  • Yes i tried with that Too... – user2520 Nov 21 '15 at 9:33
0

In Config.xml

<config>
<modules>
    <Custom_Status>
        <version>0.0.1.0</version>
    </Custom_Status>
</modules>
<global>
    <models>
        <status>
            <class>Custom_Status</class>
        </status>
    </models>
    <events>
        <sales_order_status_history_save_before>
            <observers>
                <custom_status>
                    <class>Custom_Status_Model_Observer</class>
                    <method>implementOrderStatus</method>
                </custom_status>
            </observers>
        </sales_order_status_history_save_before>
    </events>
<global>

| improve this answer | |
  • Added Abdul <class>Custom_Status_Model</class> but no improvement – user2520 Nov 21 '15 at 10:04
  • what issue is coming? – Abdul Nov 21 '15 at 10:12
  • I am facing this error Mage registry key "_singleton/Custom_Status_Model_Observer" already exists – user2520 Nov 21 '15 at 10:17
  • can you please change name Custom_Status_Model_Observer to Custom_Test_Model_Observer – Abdul Nov 21 '15 at 10:19
  • then working or not? – Abdul Nov 21 '15 at 10:19

Your Answer

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