3

I am new in magento and creating a module for use of both frontend and backend. Module works perfectly on frontend but it does not work in Magento Admin. It goes to 404 page.Here is the config file and IndexController file. Any help?

config.xml

<config>
<modules>
    <Mymodule_Customerpage>
        <version>1.0.0</version>
    </Mymodule_Customerpage>
</modules>
<admin>
    <routers>
        <the_name_of_this_element_is_not_important_it_should_be_unique>
            <use>admin</use>
            <args>
                <modules>
                <Mymodule_Customerpage before="Mage_Adminhtml">Mymodule_Customerpage</Mymodule_Customerpage>
                </modules>
            </args>
        </the_name_of_this_element_is_not_important_it_should_be_unique>
    </routers>
</admin>
<adminhtml>
    <menu>
        <tutorial_menu translate="title" module="mymodule_customerpage">
            <title>Artwork</title> 
            <sort_order>9999</sort_order>
            <children>
                <first_page module="mymodule_customerpage">
                    <title>Artwork</title> 
                    <action>adminhtml/mymodule_customerpage/index</action>
                </first_page>
            </children>
        </tutorial_menu>
    </menu>    
</adminhtml>
<frontend>
    <layout>
        <updates>
            <mymodule_customerpage module="mymodule_customerpage">
                <file>mymodule_customerpage.xml</file>
            </mymodule_customerpage>
        </updates>
    </layout>    
    <routers>
        <mymodule_customerpage>
            <use>standard</use>
            <args>
                <module>Mymodule_Customerpage</module>
                <frontName>mymodule_customerpage</frontName>
            </args>
        </mymodule_customerpage>
    </routers>        
</frontend>
<global>
<models>
    <mymodule_customerpage>
        <class>Mymodule_Customerpage_Model</class>
        <resourceModel>mymodule_customerpage_mysql4</resourceModel>
    </mymodule_customerpage>
    <mymodule_customerpage_mysql4>
        <class>Mymodule_Customerpage_Model_Mysql4</class>
        <entities>
            <customerpage>
                <table>customerpage</table>
            </customerpage>
        </entities>
    </mymodule_customerpage_mysql4>
</models>
<resources>
    <mymodule_customerpage_setup>
        <setup>
            <module>Mymodule_Customerpage</module>
        </setup>
        <connection>
            <use>core_setup</use>
        </connection>
    </mymodule_customerpage_setup>
    <mymodule_customerpage_write>
        <connection>
            <use>core_write</use>
        </connection>
    </mymodule_customerpage_write>
    <mymodule_customerpage_read>
        <connection>
            <use>core_read</use>
        </connection>
    </mymodule_customerpage_read>
</resources>
<helpers>
    <mymodule_customerpage>
        <class>Mymodule_Customerpage_Helper</class>
    </mymodule_customerpage>
</helpers>

Mymodule/Customerpage/Controller/Adminhtml/IndexController.php

class Mymodule_Customerpage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action{
public function indexAction()
{
    $this->loadLayout();

     $block = $this->getLayout()
     ->createBlock('core/text', 'adminhtml_artwork')
     ->setText('<h1>This is a text block</h1>');

    $this->_addContent($block);

    $this->renderLayout();
} }
1
  • you were able to solve it?
    – Aboodred1
    Feb 27, 2019 at 20:59

4 Answers 4

0

move your controller to Mymodule/Customerpage/Controller/Adminhtml/Customerpage/IndexController.php and rename your class to Mymodule_Customerpage_Adminhtml_Customerpage_IndexController

1
  • Thanks For help, But this does not work.
    – Abubakar
    Jan 9, 2017 at 10:53
0

You need to Logout then login again

or

follow the steps :

Step 1: Login your Magento Admin Panel.

Step 2: Go to Systems >> Permission >> Roles >> administrators >> under role info tab >> type current admin password >> save.

then check configuration. Hope it will help.

1
  • Login, logout many times. But this does not help me.
    – Abubakar
    Jan 9, 2017 at 10:55
0

On top of what Marius said, you should add the following to your controller class:

protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')->isAllowed('tutorial_menu/firstpage');
}
2
  • I tried but not work
    – Abubakar
    Jan 9, 2017 at 10:41
  • I think he has not created acl so this method has no meaning Jan 9, 2017 at 12:15
0

I think error should be here

I change just this line

   <mymodule_customerpage before="Mage_Adminhtml">Mymodule_Customerpage_Adminhtml</mymodule_customerpage> 

see Updated code at below

<admin>
<routers>
    <the_name_of_this_element_is_not_important_it_should_be_unique>
        <use>admin</use>
        <args>
            <modules>
            <mymodule_customerpage before="Mage_Adminhtml">Mymodule_Customerpage_Adminhtml</mymodule_customerpage> <!--this node should be in small-->
            </modules>
        </args>
    </the_name_of_this_element_is_not_important_it_should_be_unique>
</routers>
</admin>
8
  • Thanks for your answer but still no luck
    – Abubakar
    Jan 9, 2017 at 11:53
  • @Abubakar add Mymodule_Customerpage_Adminhtml in that node Jan 9, 2017 at 11:54
  • @Abubakar <action>adminhtml/mymodule_customerpage</action> and here remove index Jan 9, 2017 at 11:55
  • @Murtaza I copied the whole block and updated the action as well.But still does not work.
    – Abubakar
    Jan 9, 2017 at 12:01
  • Is it better to create new module for only Back-end?I mean 2 module one for Frontend(already working) and one for Back-end.
    – Abubakar
    Jan 9, 2017 at 12:02

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.