0
votes

I have gone through couple of tutorials to add custom module in Magento. I am not very familiar with Magento but I tried to follow the steps online. I am using Magento 1.7.0.2. So to add customer module I created folders as Mehul/Helloworld into app/core/local.

my Helloworld/etc/config.xml is,

<?xml version="1.0" encoding="UTF-8"?>
<!-- The root node for Magento module configuration -->
<config>

    <!--
        The module's node contains basic
        information about each Magento module
    -->
    <modules>

        <!--
            This must exactly match the namespace and module's folder
            names, with directory separators replaced by underscores
        -->
        <Mehul_Helloworld>

            <!-- The version of our module, starting at 0.0.1 -->
            <version>0.0.1</version>

        </Mehul_Helloworld>

    </modules>

      <!-- This node contains parameters, available on frontend --> 
    <frontend> 
        <!-- Module aliases are located in this block --> 
        <routers> 
            <!-- This node's name should be the same as our alias --> 
            <helloworld> 
                <!-- use parameter specifies which of basic routers needs to be used. 
                This can be "standard" for frontend or "admin" for backend --> 
                <use>standard</use> 
                <!-- router arguments block --> 
                <args> 
                    <!-- This parameter specifies the full name of out module --> 
                    <module>Mehul_Helloworld</module> 
                    <!-- This parameter sets module alias --> 
                    <frontName>helloworld</frontName> 
                </args> 
            </helloworld> 
        </routers> 
    </frontend>

</config>

my app/etc/Mehul_Helloworld.xml is,

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Mehul_Helloworld>

            <!-- Whether our module is active: true or false -->
            <active>true</active>

            <!-- Which code pool to use: core, community or local -->
            <codePool>local</codePool>

        </Mehul_Helloworld>
    </modules>
</config>

And my controller file 'IndexController.php' into Helloworld/controllers directory is,

<?php 

    class Mehul_Helloworld_IndexController extends Mage_Core_Controller_Front_Action {

        public function indexAction()
        {
            echo "Hello tuts+ World";
        }
        public function testAction()
        {
            echo "test action";
        }
    }
?>

I disabled my all catch through admin panel and I flushed it too. I can see my module is enabled when i go to System/Configuration/Advance but I try to see my controller as,

mysite.com/helloworld/index/index and mysite.com/helloworld/index/test Then I am getting an 404 error message saying that Page Not Found!

What should I do now?

  • Local
    • Mehul
      • Helloworld
        • controllers
          • IndexController.php
        • etc
          • config.xml
  • etc
    • Mehul_Helloworld.xml
5
local should be in root/app/code and lowercased. etc should be in app folder too. Try to connect mysite.com/helloworld/ - P0ZiTR0N

5 Answers

0
votes

Hi there's an online tool for module creation pretty good for new persons. This tool will give you a compressed file. You ca try this and see what mistake you are doing.

Tool url:http://www.silksoftware.com/magento-module-creator/

0
votes

Your files structure looks to be strange a little. It should be app > code > local and app > etc > modules . From task description I can see that local folder is on the same level with etc folder. Please, check this and fix. Also try to use lower case in "local" folder name.

0
votes

I think every thing is correct, but you have typed structure incorrect here . But the "Mehul_Helloworld.xml" file should be in

"app/etc/modules/Mehul_Helloworld.xml"

instead of

"app/etc/Mehul_Helloworld.xml"

. Thats may be the reason your modules is not registered.

0
votes

app/etc/Mehul_Helloworld.xml should be app/etc/modules/Mehul_Helloworld.xml

And your code must be into

/app/code/local/Mehul/Helloworld/

0
votes

Sorry guys!! It works fine, I was typing wrong URL! The URL should be 'mysite.com/store/helloworld', as my magento is installed in saperate store directory istead of root directory. And I was trying to access mysite.com/Helloworld. I realized it after I looked at my directory structure carefully! anyway, Thank you guys for the responses!