5

I'm attempting to build a module but I can't even get the url routing to work as it keeps responding with a 404. I've follow this tutorial in an attempt to get it working but I still get a 404 page every time.

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch

This is my folder structure.

app
    code
        local
            Group
                Customnewsletter
                    etc
                        config.xml
                    controllers
                        IndexController.php

My module xml is

<?xml version="1.0"?>
    <config>
        <modules>
            <Group_Customnewsletter>
                <active>true</active>
                <codePool>local</codePool>
            </Group_Customnewsletter>
         </modules>
    </config>

config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Group_Customnewsletter>
        <version>0.1</version>
    </Group_Customnewsletter>
</module>

 <frontend>
    <routers>
        <customnewsletter>
            <use>standard</use>
            <args>
                <module>Group_Customnewsletter</module>
                <frontName>customnewsletter</frontName>
            </args>
        </customnewsletter>
    </routers>
</frontend>
</config>

IndexController.php

<?php 

class Group_Customnewsletter_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction(){
        echo 'hello'; 
    }

}

The module appears under System->Configuration->Advanced and i've checked my syntax and every time i go to store.local/customnewsletter/index/index/ I get a 404 response. Any help would be greatly appreciated.

8
  • I created to module to help with this very problem. Better 404 will add router debugging information to you 404 page and tell you what's missing or wrong with your configuration. alanstorm.com/magento-404-debug Jun 18, 2014 at 3:44
  • try to load store.local/index.php/customnewsletter/index/index/ Jun 18, 2014 at 3:49
  • programmer_rk4 that didn't work. Jun 18, 2014 at 3:55
  • did you disabled all cache through admin ? Jun 18, 2014 at 4:00
  • yes, my local environment has all the cache disabled. Jun 18, 2014 at 4:03

3 Answers 3

5

In your modeule's config.xml check the below portion

<?xml version="1.0"?>
<config>
<modules>
    <Group_Customnewsletter>
        <version>0.1</version>
    </Group_Customnewsletter>
</module> <!-- This should be modules NOT module -->

Corrected code (See below):

<?xml version="1.0"?>
    <config>
    <modules>
        <Group_Customnewsletter>
            <version>0.1</version>
        </Group_Customnewsletter>
    </modules> 

Now your module should work :)

2
  • Yes, indeed. OP should enable developer mode so that this parse error can be found.
    – benmarks
    Jun 18, 2014 at 11:09
  • @benmarks♦ : Exactly :)
    – Sukeshini
    Jun 19, 2014 at 18:24
3

Per the comments above

Alan Storm. I tried your module and it did help me find an issue but now its telling me that the new frontName isn't claimed. trying to figure out why that would be as the config.xml looks good.

If the frontname isn't claimed, it means Magento isn't loading your config.xml, or there's a problem in your config.xml. I'd check the global config to make sure your config.xml's content made it in there, then I'd check the syntax of your config.xml. Then I'd look in the Mage_Core_Controller_Varien_Router_Standard::collectRoutes method to see why/if Magento's rejecting your front configuration. (in app/code/core/Mage/Core/Controller/Varien/Router/Standard.php)

1
  • In my case, your module clearly told me which file was missing (or mispelled), many thanks Alan! Dec 26, 2017 at 15:27
2

The file name needs to be IndexController.php, not indexController.php.

1
  • sorry I mistyped the name, it is IndexController.php Jun 18, 2014 at 3:53

Your Answer

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

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