0

I've added a Custom Module with front end and backend (adminhtml). Fornt end works fine but back end throws 404 when going to the newly added menu item. THe chanegs to the backend menu do appear - the URL it goes to /index.php/accessdek/adminhtml_accessdesk throws a 404 Need to know what I can do from here to diagnose?

  1. I have cleared cache and logged in and out of admin- the issue still persists
  2. I have read Alan Storm's articles on Custom Modules- Unfortunately to no avail

Here is code for adminHTML in path \app\code\local\Body1\AccessDesk\controllers\Adminhtml

class Body1_AccessDesk_Adminhtml_AccessDeskController extends Mage_Adminhtml_Controller_action {

protected function _initAction()
{
    $this->loadLayout()
        ->_setActiveMenu('accessdesk/items')
        ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
    return $this;
}    

public function indexAction() {
    $this->_initAction();        
    $this->_addContent($this->getLayout()->createBlock('accessdesk/adminhtml_accessdesk'));
    $this->renderLayout();
}

public function editAction()
{
    $accessdeskId     = $this->getRequest()->getParam('id');
    $accessdeskModel  = Mage::getModel('accessdesk/accessdesk')->load($accessdeskId);

    if ($accessdeskModel->getId() || $accessdeskId == 0) {

        Mage::register('accessdesk_data', $accessdeskModel);

        $this->loadLayout();
        $this->_setActiveMenu('accessdesk/items');

        $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
        $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));

        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

        $this->_addContent($this->getLayout()->createBlock('accessdesk/adminhtml_accessdesk_edit'))
             ->_addLeft($this->getLayout()->createBlock('accessdesk/adminhtml_accessdesk_edit_tabs'));

        $this->renderLayout();
    } else {
        Mage::getSingleton('adminhtml/session')->addError(Mage::helper('accessdesk')->__('Item does not exist'));
        $this->_redirect('*/*/');
    }
}

public function newAction()
{
    $this->_forward('edit');
}

public function saveAction()
{
    if ( $this->getRequest()->getPost() ) {
        try {
            $postData = $this->getRequest()->getPost();
            $accessdeskModel = Mage::getModel('accessdesk/accessdesk');

            $accessdeskModel->setId($this->getRequest()->getParam('id'))
                ->setTitle($postData['title'])
                ->setContent($postData['content'])
                ->setStatus($postData['status'])
                ->save();

            Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
            Mage::getSingleton('adminhtml/session')->setAccessDeskData(false);

            $this->_redirect('*/*/');
            return;
        } catch (Exception $e) {
            Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            Mage::getSingleton('adminhtml/session')->setAccessDeskData($this->getRequest()->getPost());
            $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            return;
        }
    }
    $this->_redirect('*/*/');
}

public function deleteAction()
{
    if( $this->getRequest()->getParam('id') > 0 ) {
        try {
            $accessdeskModel = Mage::getModel('accessdesk/accessdesk');

            $accessdeskModel->setId($this->getRequest()->getParam('id'))
                ->delete();

            Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
            $this->_redirect('*/*/');
        } catch (Exception $e) {
            Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
        }
    }
    $this->_redirect('*/*/');
}

}

Right now my suspicion is that this controller file is in the wrong place- Here is my Config.xml (in \app\code\local\Body1\AccessDesk\etc)

<?xml version="1.0"?> <config> <modules> <Body1_AccessDesk> <version>0.1.0</version> </Body1_AccessDesk> </modules> <frontend> <routers> <accessdesk> <use>standard</use> <args> <module>Body1_AccessDesk</module> <frontName>support</frontName> </args> </accessdesk> </routers> <layout> <updates> <accessdesk> <file>accessdesk.xml</file> </accessdesk> </updates> </layout> </frontend>
<admin> <routers> <accessdesk> <use>admin</use> <args> <module>Body1_AccessDesk</module> <frontName>accessdesk</frontName> </args> </accessdesk> </routers> </admin> <adminhtml> <menu> <accessdesk module="accessdesk"> <title>AccessDesk</title> <sort_order>71</sort_order>
<children> <items module="accessdesk"> <title>Manage Items</title> <sort_order>0</sort_order> <action>accessdesk/adminhtml_accessdesk</action> </items> </children> </accessdesk> </menu> <acl> <resources> <all> <title>Allow Everything</title> </all> <admin> <children> <accessdesk> <title>AccessDesk Module</title> <sort_order>200</sort_order> </accessdesk> </children> </admin> </resources>
</acl> <layout> <updates> <accessdesk> <file>accessdesk.xml</file> </accessdesk> </updates> </layout> </adminhtml> <global> <models> <accessdesk> <class>Body1_AccessDesk_Model</class> <resourceModel>accessdesk_mysql4</resourceModel> </accessdesk> <accessdesk_mysql4> <class>Body1_AccessDesk_Model_Mysql4</class> <entities> <accessdesk> <table>accessdesk</table> </accessdesk> </entities> </accessdesk_mysql4> </models> <resources> <accessdesk_setup> <setup> <module>Body1_AccessDesk</module> </setup> <connection> <use>core_setup</use> </connection> </accessdesk_setup> <accessdesk_write> <connection> <use>core_write</use> </connection> </accessdesk_write> <accessdesk_read> <connection> <use>core_read</use> </connection> </accessdesk_read> </resources> <blocks> <accessdesk> <class>Body1_AccessDesk_Block</class> </accessdesk> </blocks> <helpers> <accessdesk> <class>Body1_AccessDesk_Helper</class> </accessdesk> </helpers> </global> </config>

  • Did you log out of admin and log back in? – pspahn Aug 7 '14 at 21:49
  • Also did you delete the cache and re-index? – Egregory Aug 7 '14 at 22:22
  • please show us your code – David Manners Aug 8 '14 at 4:43
  • Try naming your controller file AccessdeskController instead of AccessDeskController – Marius Aug 12 '14 at 14:50
  • Actually it turns out that naming my controller IndexController (and class code and config accordingly did the trick. do not know why it did not like AccessDeskController However Marius your suggestion did come closest to answering Thanks – user3351831 Aug 12 '14 at 19:25
2

Clearing cache & logging out/back in to admin should solve your issue. Magento's adminhtml stores ACL privileges in session data - thus the need to relog.

For some interesting reading on what goes on behind the scenes grab a bag of popcorn and check out: http://alanstorm.com/magento_acl_authentication

2

According @marius.You need to change class name space and file name of controller file

file AccessdeskController instead of AccessDeskController

same change need also class name

Body1_AccessDesk_Adminhtml_AccessDeskController

should be Body1_AccessDesk_Adminhtml_AccessdeskController

  • Can you not have modules with upper case in the middle of the module name? E.g. MyCompany_MyModule. Is it better to have Mycompany_Mymodule? – Michael Jan 13 '16 at 6:56
  • Yes.it better to use First Letter upper & then all lower – Amit Bera Jan 13 '16 at 7:24
  • AmitBera do you know what place MyModule type module names breaks the convention? – Michael Jan 13 '16 at 7:29
  • michel,little bit of busy now. Will be reply soon – Amit Bera Jan 13 '16 at 7:31
  • Amit, I found that it doesn't work in layouts <block type="mycompany/adminhtml_mymodulebackend" /> will not work. It will become Adminhtml/Mymodulebackend. – Michael Jan 13 '16 at 9:31
0

1) Make sure you've cleared your cache and logged in and out of the administration area 2) The URL translates to a controller in the module. http://foobar.com/module/controller/action

e.g. http://foobar.com/kimit/catalog/text

  • I open the KimIT module.
  • Look in the controllers directory for catalogController.php.
  • Search in there for the function textAction()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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