2

I have created one module in magento 1.9.2.4 and I want to check front end controller is working or not,but get an error 404 Not Found page.

Config.xml (C:\xampp\htdocs\shop\app\code\local\Sevenbits\Demo\etc\config.xml)

<?xml version="1.0"?>
<config>
    <!-- about modules -->
    <modules>
        <Sevenbits_Demo>
            <version>1.0.0</version>
        </Sevenbits_Demo>
    </modules>


    <!-- Setup  class  path for all things -->
    <global>
        <models>
        <demo>
            <class>Sevenbits_Demo_Model</class>
        </demo>
        </models>

        <blocks>
        <demo>
            <class>Sevenbits_Demo_Block</class>
        </demo>
        </blocks>

        <helpers>
        <demo>
            <class>Sevenbits_Demo_Helper</class>
        </demo>
        </helpers>
    </global>

    <!-- For Frontend Controller-->

    <frontend>
        <routers>
            <demo>
                <use>standard</use>
                <args>
                    <frontName>demo</frontName>
                    <module>Sevenbits_Demo</module>
                </args>
            </demo>
        <routers>
    </frontend>

</config>

IndexController.php (C:\xampp\htdocs\shop\app\code\local\Sevenbits\Demo\controllers\IndexControllers.php)

<?php


class Sevenbit_Demo_IndexControllers extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {

            echo "Hello World";
    }


}

Sevebits_Demo.xml (C:\xampp\htdocs\shop\app\etc\modules\Sevenbits_Demo.xml)

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

You can find full source code here : https://drive.google.com/file/d/0B8PWEkckbXCUNkpQZ2N6eEM3a1E/view?usp=sharing

2

2 Answers 2

3

you need to change in two files as below in your module,

1./app/code/local/Sevenbits/Demo/controllers/IndexController.php class name is wrong, replace with below code,

<?php


class Sevenbits_Demo_IndexController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {

            echo "Hello World";
    }


}

2. config.xml

<!-- For Frontend Controller-->

    <frontend>
        <routers>
            <demo>
                <use>standard</use>
                <args>
                    <frontName>demo</frontName>
                    <module>Sevenbits_Demo</module>
                </args>
            </demo>
        </routers>
    </frontend>

Note: After I made this two changes in your module, I am getting below response in my browser when i run url, http://localhost/magento1924/index.php/demo/index

https://drive.google.com/file/d/0B1aJL9nhfbfFRzNTdGwzYWxFR0k/view?usp=drivesdk

0
0

If you replace this bit:

      <demo>
            <use>standard</use>
            <args>
                <frontName>Test</frontName>
                <module>Sevenbits_Demo</module>
            </args>
        </demo>

With:

      <demo>
            <use>standard</use>
            <args>
                <frontName>demo</frontName>
                <module>Sevenbits_Demo</module>
            </args>
        </demo>

You will be able to access your controller with: http://magentourl.com/demo

If you need to access it with http://magentourl.com/test you ll have to change it to:

      <test>
            <use>standard</use>
            <args>
                <frontName>test</frontName>
                <module>Sevenbits_Demo</module>
            </args>
        </test>

Basically the <frontName> node needs to match your URL path

On top of that your controller class name is missing an "s" it should be:

Sevenbits_Demo_IndexController

Also remove the extra "s" after IndexController in both your class name and your file name

9

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.