0
votes

I have created a custom module that adds two menus in catalog. I have also created a controller for one of the menu , but the controller never gets called but instead is redirected to the admin dashboard page.

My question is some what related to this question Magento admin routing isn't working

I have tried the suggestions mentioned in the answers but none of them worked for me.

When ever I call the url http://localhost/compare/index.php/ecomm/index/key/bb9f436ee373421b170aa862a1cbb305/

I get redirected to http://localhost/compare/index.php/admin/dashboard/index/key/bb9f436ee373421b170aa862a1cbb305/ and hello world never gets printed.

I'm using magento 1.9 and have disabled all the caches.

My module name is Super_Awesome and below is the directory structure

Super
|
|-Awesome
  |-etc          (adminhtml.xml, config.xml)
  |-controllers  (ManageEcomm.php)
  |-Helper       (Data.php)

The config file in app/etc/modules/Super_Awesome.xml is as follows

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

The config file in app/code/local/Super/Awesome/etc/config.xml is

<?xml version="1.0"?>
<config>
    <modules>
        <Super_Awesome>
            <version>0.1.0</version>
        </Super_Awesome>
    </modules> 

    <admin>
        <routers>
            <ecomm>
                <use>admin</use>
                <args>
                    <module>Super_Awesome</module>
                    <frontName>ecomm</frontName>
                </args>
            </ecomm>
        </routers>
    </admin>
    <adminhtml>
        <!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
        <acl>
            <resources>
                <admin>
                    <children>
                        <catalog>
                            <!--<title>Awesome Menu Item</title>-->
                            <children>
                                <example translate="title" module="awesome">
                                    <title>Manage Ecommerce</title>
                                </example>
                                <example1 translate="title" module="awesome">
                                    <title>Manage Ecommerce Pages</title>
                                </example1>
                            </children>
                        </catalog>
                    </children>
                </admin>
            </resources>
        </acl>

    </adminhtml>

    <global>
        <helpers>
            <awesome>
                <class>Super_Awesome_Helper</class>
            </awesome>
        </helpers>
    </global>

</config>

Controller app/code/local/Super/Awesome/controllers/IndexController.php

<?php
class Super_Awesome_IndexController extends Mage_adminhtml_Controller_Action
{
    public function indexAction()
    { 
        echo "hello world";
        exit();
    }
}

Finally the adminhtml.xml file in app/code/local/Super/Awesome/etc/

<?xml version="1.0"?>
<config>
    <menu>
        <catalog translate="title" module="awesome">
            <!--<title>Awesome</title>
            <sort_order>15</sort_order>-->
            <children>
                <example translate="title" module="awesome">
                    <title>Manage Ecommerce</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/ecomm</action>
                </example>
                <example1 translate="title" module="awesome">
                    <title>Manage Ecommerce Pages</title>
                    <sort_order>2</sort_order>
                    <action>adminhtml/example/index</action>
                </example1>
            </children>
        </catalog>
    </menu>
</config>
2

2 Answers

2
votes

I think you have missed the part where you add your new module as a router for adminhtml in etc/config.xml. It should be something like this:

When Magento tries to find a controller file for an admin URL, it will also check for any module configured inside this <modules/> tag.

<config>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Super_Awesome after="Mage_Adminhtml">Super_Awesome</Super_Awesome>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>
0
votes

I finally found it the hard way that it's not good to create a module by yourself. If you make a mistake you could end up your precious time finding where things went wrong.

Its best to install a module creator extension from Ultimate Module Creator or use a online tool provided by Silk