I am trying to add an event observer to run before product page load. I am receiving an error.
Here is my config.xml
<config>
<frontend>
<events>
<catalog_product_load_before>
<observers>
<product_load_handler>
<class>hsc_pce/observer</class>
<method>productLoadHandler</method>
</product_load_handler>
</observers>
</catalog_product_load_before>
</events>
</frontend>
</config>
Here is my observer function
public function productLoadHandler(Varien_Event_Observer $observer)
{
echo 'foobar';
return;
}
I receive the echo and this error
foobar
Fatal error: Call to a member function getRequestedRouteName() on a non-object in app/code/core/Mage/Core/Controller/Varien/Action.php on line 226
The echo demonstrates that the function is being called. Error occurs without echo as well. If I die()
before return I do not receive the error, so it's happening afterwards.
The error is in a line that is part of the getFullActionName($delimiter='_')
function, which is called by the dispatch($action)
function.
I've tried digging deeper, leading me to alter the request
object, but it's clear that it's leading nowhere and is not the appropriate solution.
What is causing this error, and how can I prevent it?
Update
Mage::app()->getRequest()->getRequestedRouteName()
shows that the requested route name is 'catalog'.