Magento – Custom Module back end keeps coming up as a 404

404backendmodule

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>

Best Answer

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

Related Topic