I have truble with observer, don't know how to solve it!

Here is part of the config.xml and Observer.php files


<?xml version="1.0"?>    


class Mycompany_Mymodule_Model_Observer 
    protected $_config;

    protected function _construct()
        $this->_config = Mage::getModel('mymodule/config');

    public function mymoduleCompleteOrder($observer)
  • Is the rest of your module working? Do you have the module declaration file in app/etc/modules ?
    – Marius
    Apr 7, 2014 at 20:37
  • yes, working fine, only observer do not work!
    – sIiiS
    Apr 7, 2014 at 20:54
  • IN the config.xml you declared your method used for the event mymoduleCompleteOrder and in the observer the method name is mymodulesCompleteOrder. There is an additional s in the observer class. Could that be it?
    – Marius
    Apr 7, 2014 at 20:57
  • it my fault in write here! both same!
    – sIiiS
    Apr 7, 2014 at 21:07
  • try Mage::getModel('mymodule/observer'); if this works try $observer-> mymoduleCompleteOrder('test'); if this works too, you need to check, whether the event is fired!? Apr 7, 2014 at 21:21

1 Answer 1


I do not know what exactly problem you have, but I see one problem in your code.

In your observer you have _construct() method.

It is not the php constructor (php constructor has two underscores).

Also your observer does not extend Mage_Core_Model_Abstract which runs _construct()` method during object initialization.

So as a result _construct() will not be executed and protected $_config; will always be null.

If you use $this->_config in mymoduleCompleteOrder(), it can generate error, and your code is not executed correctly.

  • Yes true, I removed protected $_config; and _construct() from my code and then worked fine
    – sIiiS
    Apr 8, 2014 at 20:40

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.