I am trying to make an extension containing an observer.

But magento search the model in mage instead of my local extension "Test". system.log tells me:

Failed opening 'Mage/Sync/Model/Observer.php' for inclusion

My /app/code/local/Test/Sync/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>


class Test_Sync_Model_Observer {
    public function export($observer)
      // code

I checked file access and cleared all caches.

Why does he not use my observer?


The problem is so far not really related to the observer mechanism. It is a more basic problem.

When Magento tries to load files like Mage/Yourmodule/Model/Foo.php, this indicates that the lookup of the Magento class code (i.e. sync/observer or yourmodule/foo for my example) in Mage::getModel() (Magento calls getModel() internally when initializing the observer) did not work properly.

The code to be written in the <class> ... </class> node follows the same logic as you would pass it to getModel().

What you did is to define a mapping from test -> Test_Sync_Model. So if you use

<class>test/observer</class> Magento should properly use Test_Sync_Model_Observer.

But you actually might have intended to define the alias test_sync (which is more common). So in the models section it must be <test_sync> and in the observer <class>test_sync/observer</class>.


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.