1

Below I have pasted my observer and config as I currently have them.

app/code/local/Skytiger/Redirection/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <models>
        <redirection>
            <class>Skytiger_Redirection_Model</class>
        </redirection>
    </models>
    <frontend>
        <events>
            <controller_action_predispatch_cms_page_view>
                <observers>
                    <skytiger_redirection>
                        <type>model</type>
                        <class>skytiger_redirection/observer</class>
                        <method>controllerActionPredispatchCmsPageView</method>
                    </skytiger_redirection>
                </observers>
            </controller_action_predispatch_cms_page_view>
        </events>
    </frontend>
</config>

app/code/local/Skytiger/Redirection/Model/Observer.php:

<?php
class Skytiger_Redirection_Model_Observer/* extends Mage_Core_Model_Observer*/
{
    public function controllerActionPredispatchCmsPageView(Varien_Event_Observer $observer)
    {
        /** code here ... */

    }
}

When trying to hit the /home page (which should then be redirected to /), I get the following error:

Warning: include(Mage/Skytiger/Redirection/Model/Observer.php): failed to open stream: No such file or directory in /var/www/clean.magento.181/magento/lib/Varien/Autoload.php on line 93

Now, the error tells me that it's not looking for the correct file. It says it's looking for Mage/Skytiger/Redirection/Model/Observer.php instead of for Skytiger/Redirection/Model/Observer.php, which means that there is an error in my config.xm somewhere. Need some help finding that problem, though.

2 Answers 2

2

use <class>redirection/observer</class> insetad of <class>skytiger_redirection/observer</class>

you are missing the global tag also models alwasy define in <global> tag

<global>
  <models>
        <redirection>
            <class>Skytiger_Redirection_Model</class>
        </redirection>
    </models>
</global>

your complete config.xml look like

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
       <Skytiger_Redirection>
         <version>1.1.0</version>
        </Skytiger_Redirection>
     </modules>
   <global>
    <models>
        <redirection>
            <class>Skytiger_Redirection_Model</class>
        </redirection>
    </models>
   </global>
    <frontend>
        <events>
            <controller_action_predispatch_cms_page_view>
                <observers>
                    <skytiger_redirection>
                        <type>model</type>
                        <class>redirection/observer</class>
                        <method>controllerActionPredispatchCmsPageView</method>
                    </skytiger_redirection>
                </observers>
            </controller_action_predispatch_cms_page_view>
        </events>
    </frontend>
</config>
3
  • When I do that, I get the same error except that it no longer looks for skytiger at all: Warning: include(Mage/Redirection/Model/Observer.php): failed to open stream: No such file or directory in /var/www/clean.magento.181/magento/lib/Varien/Autoload.php on line 93
    – Skytiger
    Apr 25, 2016 at 11:38
  • added the solution you were missing the <global></global> tag Apr 25, 2016 at 11:42
  • 1
    Cue me slamming my head in a door for being an idiot... Thanks, that did it!
    – Skytiger
    Apr 25, 2016 at 12:10
4

replace in config.xml this

<redirection>
    <class>Skytiger_Redirection_Model</class>
</redirection>

with

<skytiger_redirection>
    <class>Skytiger_Redirection_Model</class>
</skytiger_redirection>

and clear the cache. And move the <models> section inside the <global> tag instead of <config>.

2
  • I don't cache when I develop, so that's not a problem. Isn't that node in the config just a unique name?
    – Skytiger
    Apr 25, 2016 at 11:37
  • 1
    No. It's the alias of your models In other words it's the part before the slash in Mage::getModel('something/here')
    – Marius
    Apr 25, 2016 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.