404 Error on Magento Adminhtml Module - magento

I've created a fairly straight forward module for mageneto with an administration section.
The Admin section works perfectly except that I get a 404 error when I hit 'Add Item'.
What is particularly odd is that the 'new' action just forwards to the 'edit' action and the edit action works fine:
public function newAction()
{
$this->_forward('edit');
}
All the forum posts I've read suggests that this is an issue with the ACL as set in my config.xml but I've tried endless permutation and combinations, loggin out and back in again to test them all and none of them seem to work.
The ACL section of config.xml looks like this:
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<press>
<title>Press Module</title>
<sort_order>10</sort_order>
</press>
</children>
</admin>
</resources>
Also, if I change the newAction to just echo something it works fine.
Any other ideas about what it could be? Surely if the controller just forwards to the Edit page and the edit page is fine I shouldn't be seeing a 404 error.

A bit of a shot in the dark but perhaps you could try $this->_redirect() instead of _forward

You are missing something in your module config.xml. I was facing same situation but when I added the following code ... it work fine for me
<admin>
<routers>
<yourmodule>
<use>admin</use>
<args>
<module>Yournamespace_Yourmodule</module>
<frontName>yourmodule</frontName>
</args>
</yourmodule>
</routers>
</admin>

Related

Magento Extension causes 404 Error from the Admin Panel

We have a Magento Extension on our website, written by an ex-employee. This extension was written just for this one website, and I am struggling to find out what is going wrong with this extension. Contacting the ex-employee has proven to be (how should I put this), an ineffective method for solving this problem, so I was hoping someone here could help me out.
The extension works fine on the site, but when we click on the extension in the backend, on the Admin Panel, we get a "404 Not Found 1" error.
Is there anything I can do (like changing log file settings) to find out what file is missing and causing this 404?
QUICK UPDATE
After rolling back a load of patches we have noticed that this problem only occurs after patch 5994. Is there anything in patch 5994 that could be causing these problems?
The extension itself has the following files:
\app\code\local\muz\Worldman\controllers\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\Adminhtml\
WorldmanController.php
\app\code\local\muz\Worldman\controllers\etc
config.xml
\app\code\local\muz\Worldman\controllers\Helper
Data.php
I can make changes to the class names in the \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php and instead of getting a 404 error, I get an actual crash report, stating that Controller file was loaded but class does not exist.
Again, this extension works fine on the site itself. Its just clicking on the extension itself from the Admin Panel menu that causes the 404.
The extension is enabled. I have logged out and back in a hundred times. Indexes have been re-indexed. Caches have been cleared and turned off. Servers have been rebooted. But to no avail.
At this point any suggestions for debugging any Magento extensions would be very much appreciated.
If this helps, here is the config.xml file:
<?xml version="1.0"?>
<config>
<modules>
<muz_Worldman>
<version>1.0.0</version>
</muz_Worldman>
</modules>
<global>
<helpers>
<worldman>
<class>muz_Worldman_Helper</class>
</worldman>
</helpers>
</global>
<frontend>
<routers>
<worldman>
<use>standard</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</frontend>
<adminhtml>
<menu>
<cms>
<children>
<worldman_adminform translate="title" module="worldman">
<title>Worldman Manager</title>
<action>worldman/adminhtml_worldman</action>
</worldman_adminform>
</children>
</cms>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<cms>
<children>
<worldman_adminform>
<title>worldman Manager</title>
</worldman_adminform>
</children>
</cms>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<worldman>
<file>worldman.xml</file>
</worldman>
</updates>
</layout>
</adminhtml>
</config>
The ACL settings are not set right for the user, that's why you get a 404. Even with the ACL set correctly you might get this error if you do not flush the Magento config cache and log out and then back in again.
From a quick look at your config, it seems like the XML part of the ACL settings is alright, but you might need to check if the file \app\code\local\muz\Worldman\controllers\Adminhtml\WorldmanController.php has a method like this in it:
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('cms/worldman_adminform');
}
I had a bunch of modules that stopped working because of this missing method after one of Magento's latest patches.
Also, did you try with an admin account where you should automatically have full access?
--------EDIT-------
The patch you mentioned (5994) gave me similar problems with one of my modules. It used frontend routing for the adminhtml-controller, so what I had to do was to remove the XML between <frontend>...</frontend> and replace it with something like this:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<muz_Worldman after="Mage_Adminhtml">muz_Worldman_Adminhtml</muz_Worldman>
</modules>
</args>
</adminhtml>
<worldman>
<use>admin</use>
<args>
<module>muz_Worldman</module>
<frontName>worldman</frontName>
</args>
</worldman>
</routers>
</admin>
and also make sure that the the XML for ACL action - <action>worldman/adminhtml_worldman</action> is right, I had to make some changes to the URL so mine became more like (for you) adminhtml/worldman_adminform.

Unable to run a simple install script

I am trying to follow This tutorial, somewhat unsuccessfully!
I have got to the point where my script should display "Running This Upgrade: Myname_Weblog_Model_Resource_Setup Exit for now". This does not happen.
I believe it is something to do with my config file but looking though it I cannot work out what is wrong.
I have put a die statement into the setup.php file and that killed the script as expected. I then removed the die statement from setup.php and placed it into mysql4-install-0.1.0.php, this had no effect and the script continued on to render data from my controller.
I have added the code which I have been looking at to try and find the solution (as well as the full folder structure, hopefully its clear enough), could someone please advise me where the problem is or where else I should be looking to resolve this issue.
Myname
Weblog
Model
Resource
Blogpost
-Collection.php
-Blogpost.php
-Setup.php
-Blogpost.php
controllers
-IndexController.php
etc
-config.xml
sql
weblog_setup
-mysql4-install.0.1.0.php
Myname/Weblog/etc/config.xml
<config>
<modules>
<Tonysimpson_Weblog>
<version>0.1.0</version>
</Tonysimpson_Weblog>
</modules>
<global>
<models>
<weblog><!--group name, matches the module name-->
<class>Tonysimpson_Weblog_Model</class><!--Base name allmodels in the weblog group will have-->
<resourceModel>weblog_resource</resourceModel><!--indicagtes which resource model should be used-->
</weblog>
<weblog_resource>
<class>Tonysimpson_Weblog_Model_Resource</class>
<entities>
<blogpost>
<table>blog_posts</table>
</blogpost>
</entities>
</weblog_resource>
</models>
<resources>
<weblog_setup>
<setup>
<module>Tonysimpson_Weblog</module>
<class>Tonysimpson_Weblog_Model_Resource_Setup</class>
</setup>
</weblog_setup>
</resources>
</global>
<frontend>
<routers>
<weblog>
<use>standard</use>
<args>
<module>Tonysimpson_Weblog</module>
<frontName>weblog</frontName>
</args>
</weblog>
</routers>
</frontend>
MyName/Weblog/Model/Resource/Setup.php
class Tonysimpson_Weblog_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
{
}
Myname/Weblog/sql/weblog_setup/mysql4-install-0.1.0.php
echo 'running this upgrde: ' . get_class($this) . "\n <br /> \n";
die("exit for now");
checkout forweblog_setup in core_resoruce table, if your resource(weblog_setup) is present in this table than your installer will not run, what you can do is make an backup of your core_resource and delete its entry for weblog_setup OR else you can try to write an upgrade script.
You can try to delete setup class and see if there will be any error. So you will now then if config.xml is OK.
Also check in database the core_resoruce table or something like that. Maybe it's already installed and this is why it can't run again.
Also delete cache.
What server do you use ? ngnix or apache? Because I had a client that has the first one and there was some permission problem and because of that extensions didn't install.

Magento Hello World Admin Module Returning 404

I'm having a go at building an admin module using the moduleCreator tool found here
Even out of the box it is throwing a 404 when I navigate to the page. I have disabled cash and logged out/in. None of the googled solutions fix the issue. I am running 1.7.2
The key files look like this:
Config.xml
<?xml version="1.0"?>
<config>
<modules>
<Jinkou_MobileAdmin>
<version>0.1.0</version>
</Jinkou_MobileAdmin>
</modules>
<global>
<helpers>
<mobileadmin>
<class>Jinkou_MobileAdmin_Helper</class>
</mobileadmin>
</helpers>
<blocks>
<mobileadmin>
<class>Jinkou_MobileAdmin_Block</class>
</mobileadmin>
</blocks>
</global>
<admin>
<routers>
<mobileadmin>
<use>admin</use>
<args>
<module>Jinkou_MobileAdmin</module>
<frontName>mobileadmin</frontName>
</args>
</mobileadmin>
</routers>
</admin>
<adminhtml>
<menu>
<mobileadmin module="mobileadmin">
<title>MobileAdmin</title>
<sort_order>100</sort_order>
<children>
<mobileadminbackend module="mobileadmin">
<title>Order Processing</title>
<sort_order>0</sort_order>
<action>mobileadmin/adminhtml_mobileadminbackend</action>
</mobileadminbackend>
</children>
</mobileadmin>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<mobileadmin translate="title" module="mobileadmin">
<title>MobileAdmin</title>
<sort_order>1000</sort_order>
<children>
<mobileadminbackend translate="title">
<title>Order Processing</title>
</mobileadminbackend>
</children>
</mobileadmin>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<mobileadmin>
<file>mobileadmin.xml</file>
</mobileadmin>
</updates>
</layout>
</adminhtml>
</config>
MobileBackendController.php
<?php
class Jinkou_MobileAdmin_Adminhtml_MobileAdminbackendController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->_title($this->__("Order Processing"));
$this->renderLayout();
}
}
The MobileAdminbackendController.php does not seem to be loading as I can remove the class and not throw an exception.
Make Sure the following files are there inside the proper folders as given below :
app\code\local\Jinkou\MobileAdmin\Block\Adminhtml\MobileAdminbackend.php
app\code\local\Jinkou\MobileAdmin\controllers\Adminhtml\MobileAdminbackendController.php
app\code\local\Jinkou\MobileAdmin\etc\config.xml
app\code\local\Jinkou\MobileAdmin\Helper\Data.php
app\design\adminhtml\default\default\layout\mobileadmin.xml
app\design\adminhtml\default\default\template\mobileadmin\mobileadminbackend.phtml
app\etc\modules\Jinkou_MobileAdmin.xml
Can you go to the following settings page and check if you can fing "Jinkou_MobileAdmin" in the list?
System -> Configuration -> Advanced
If you can't find it there, you might have forgotten to add the module XML file in your code, to add this, go to:
app -> etc -> modules
Just copy other XML and edit the data in it to your module.
Make sure you name your file "Jinkou_MobileAdmin.xml".
I am on magento 1.8 and I fixed my error(404) by doing the following. Inside Magentotutorial_Helloworld.xml put below code:
codePool local codePool
since I do not have a local folder I put mine into the community folder. Change the code to this and it will work.
'codePool community codePool'

Custom menu gives 404 in magento on server

I created a custom menu in admin tab in magento admin. It was working perfectly on localhost, but when i deployed my code on the server, it is giving a 404 page not found error. What can be the issue there!
<?xml version="1.0"?>
<config>
<modules>
<Inchoo_CoffeeFreak>
<version>0.1.0</version>
</Inchoo_CoffeeFreak>
</modules>
<global>
<blocks>
<coffefreakblock1>
<class>Inchoo_CoffeeFreak_Block</class>
</coffefreakblock1>
<coffefreakblock2>
<class>Inchoo_CoffeeFreak_Block_EditSpecial</class>
</coffefreakblock2>
</blocks>
<helpers>
<coffefreakhelper1>
<class>Inchoo_CoffeeFreak_Helper</class>
</coffefreakhelper1>
</helpers>
</global>
<admin>
<routers>
<samplerouter1>
<use>admin</use>
<args>
<module>Inchoo_CoffeeFreak_AdminControllersHere</module>
<frontName>print</frontName>
<modules>
<sintax after="Inchoo_CoffeeFreak_AdminControllersHere">Mage_Adminhtml</sintax>
</modules>
</args>
</samplerouter1>
</routers>
</admin>
<adminhtml>
<menu>
<mymenu1 translate="title" module="coffefreakhelper1">
<title>PrintInfo</title>
<sort_order>20</sort_order>
<children>
<!-- Note the misleading "module" attribute.
It actualy refers to one of the declared helpers -->
<myitem1 translate="title" module="coffefreakhelper1">
<title>Add/Change Config</title>
<action>samplerouter1/settings</action>
<sort_order>1</sort_order>
</myitem1>
</children>
</mymenu1>
</menu>
</adminhtml>
</config>
Your server may be running on Linux which is case sensitive so you need to check that you module file and folder should be according Magento standard like controller should be IndexController not indexController etc.
and your localhost running on window which is not case sensitive.
Normally this is when you are logged in. Logout and login again. Then it should work.
Assuming that cache is turn off / cleared
1) Logout and log back in again
If you still getting a 404 error
2) Check your server error log, you maybe missing your module helper file
Login In/Out,clear cache, should be the solution.But you can try below points (though it may find foolish).
1) Check your xml contents.(line by line with your localhost xml)
2) Spellings matter (hope <sintax> spelling is correct is your xml )
3) Remove unwanted space (like before <global> tag) and comments.
4) Opening & closing of tags.
5) Proper Indentation (this will help to find your flaw if it is there)
6) Atlast directly copy the same localhost xml file in your server.
I really wish this will help you to find the bug.

Add module into admin html in Magento

I made a module Filfact_Partners in the local in Magento.
This module is a part in admin management.
Here is it's structure:
local
-----/Filfact
-------------/Partners
----------------------/Block
----------------------/Helper
----------------------/Model
----------------------/etc
----------------------/controllers
----------------------------------/Adminhtml
--------------------------------------------/PartnerController.php
At config.xml file, I added some code to menu:
<menu>
<partners>
<title>Partners</title>
<sort_order>71</sort_order>
<children>
<partner module="partners">
<title>Manage Partners</title>
<action>adminhtml/partner</action>
</partner>
</children>
</partners>
</menu>
But when I request the url: http://localhost/index.php/admin/partner/index, it does not work.
So my question is: how can I request the above url, it will active: controllers/adminhtml/PartnerController.php controller.
If something is not clear, please ask me, all of your help are great things to me.
You should configure routes for your module. In the config.xml file of yout module the following should be added (inside config node):
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Filfact_Partners before="Mage_Adminhtml">Filfact_Partners_Adminhtml</Filfact_Partners>
</modules>
</args>
</adminhtml>
</routers>
</admin>

Resources