What I'm trying to do is to override one single method in Model/Observer.php
of other module. I followed this tutorial: http://www.atwix.com/magento/overriding-observers/.
As a result I've created my own module.
Its etc\config.xml
:
<?xml version="1.0"?>
<config>
<modules>
<Package_MyModule>
<version>1.0.0</version>
<platform>ce</platform>
</Package_MyModule>
</modules>
<global>
<helpers>
<mymodule>
<class>Package_MyModule_Helper</class>
</mymodule>
</helpers>
<models>
<mymodule>
<class>Package_MyModule_Model</class>
</mymodule>
<theirmodule>
<rewrite>
<observer>mymodule/observer</observer>
</rewrite>
</theirmodule>
</models>
</global>
<frontend>
<events>
<event_name>
<observers>
<their_controller_predispatch>
<type>disabled</type>
</their_controller_predispatch>
<mymodule_controller_predispatch>
<type>singleton</type>
<class>mymodule/observer</class>
<method>someObserverMethod</method>
</mymodule_controller_predispatch>
</observers>
</event_name>
</events>
</frontend>
</config>
My observer class itself extends initial observer class (and also my module depends on initial module):
class Package_MyModule_Model_Observer extends Package_TheirModule_Model_Observer
{
public function someObserverMethod($observer)
{
...
}
}
Initial module has several events, that are handled by that observer class (let's say, 10).
When I try to run my code I get the following error: "Mage registry key "_singleton/mymodule/observer" already exists"
. I've tried all solutions for this error from magento.stackexchange.com and none of them worked for me.
But, and that is interesting, when I add all other missed events to my config.xml
(9 of those, that I do not want to override), everything works fine. But I do not want to do that, cause I lose advantages of overriding then.
So my question is: how to override only one method of observer of other module and not get this strange error?
config.xml
<class>Package_MyModule_Model_Observer</class>
see: stackoverflow.com/questions/19142720/…