# How to update admin routers of custom module for patch SUPEE-6788

I'm not sure how to update custom modules to work with the SUPEE-6788 patch, the instructions are not very clear.

Based on Alan Storm's tutorial, I created a simple module in the generator www.silksoftware.com/magento-module-creator/ for testing. It has custom page in admin which works perfectly fine, but when I apply fixes required in SUPEE-6788, the admin page shows 404 error.

URL of the custom admin page is:

Here's the config of the module:

<config>
<modules>
<version>0.1.0</version>
</modules>
<global>
<helpers>
</helpers>
<blocks>
</blocks>
</global>
<routers>
<args>
</args>
</routers>
...


Here's the controller:

class Pulsestorm_Adminhello_Adminhtml_AdminhellobackendController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();$this->_title($this->__("My Test Page Title"));$this->renderLayout();
}
}


## Solution

I replaced the <routers> part based on instructions from the patch like this (probably incorrectly):

<routers>
<args>
<modules>
</modules>
</args>
</routers>


But now the URL just shows 404 error:

How to fix the module correctly for that new patch? Do I just need to update config.xml or do I also need to change the admin page's URL after applying this patch?

I managed to change my custom module to use the Magento new way as recommended with the patch 6788. So I give here as a reference for other, also answer the question in this thread.

1. Change to router in the config.xml file:

Before:

<admin>
<routers>
<args>
</args>
</routers>


After

<admin>
<routers>
<args>
<modules>
</modules>
</args>
</routers>

1. Change to the Controller

2.1.

Before Path

/app/code/local/Pulsestorm/Adminhello/controllers/Adminhtml/AdminhellobackendController.php


After path

/app/code/local/Pulsestorm/Adminhello/controllers/Adminhtml/Adminhello/AdminhellobackendController.php


2.2

Before class

class Pulsestorm_Adminhello_Adminhtml_AdminhellobackendController extends Mage_Adminhtml_Controller_Action
{
..
}


After class

class Pulsestorm_Adminhello_Adminhtml_Adminhello_AdminhellobackendController extends Mage_Adminhtml_Controller_Action
{
...
}

1. If you have an adminhtml.xml file (just give as an example as below)

Before

<config>
<sort_order>100</sort_order>
<children>
<title>Manage Hellos</title>
<sort_order>4</sort_order>
</list_action>
...
</children>
</config>


After

<?xml version="1.0" encoding="UTF-8"?>
<config>
<sort_order>100</sort_order>
<children>
<title>Manage Hellos</title>
<sort_order>4</sort_order>
</list_action>
...
</children>
</config>

1. Change in your codes

Before: getting URLs

Mage::getUrl('adminhello/adminhtml_adminhellobackend/doSomething')


After: getting URLs

Mage::getUrl('adminhtml/adminhello_adminhellobackend/doSomething')

1. Change in layout files (if you have layout files, for example as below)

Before layout

<adminhello_adminhtml_adminhellobackend_index>
...


After layout

<adminhtml_adminhello_adminhellobackend_index>
...

• Excellent! Worked like a charm! – BENN1TH Mar 25 '16 at 8:12

I lost hours figuring this out. Just because the Devs at Magento aren't capable of making an understandable configuration, or yet even documenting their code in a way a human being would be able to read it.

Let's have a look at the config.xml first

<routers>
<args>
<modules>
</modules>
</args>


The whole meaning of the Tags has changed. The Tag under "modules" is just a random name. you just need to make sure its unique to ensure it is not overwritten when the XML is compiled. It has influence on the URL.

<admin_adminhello after= ..... >


Magento now expects you to move your backend controller classes into a new subfolder called "adminhtml" This is why in the config.xml you have to change the class name suffix by adding _Adminhtml.

... >Pulsestorm_Adminhello_Adminhtml</admin_adminhello> ....


In your case the folder would be located at

Now the real Problem. Using the other (better) system you had your own namespace defined by using the "FrontName" Tag. You don't have this luxury any more, so you need to make sure your controller has a unique name. Otherwise it would conflict with other Extensions. So controllers named something like "AdminController.php" are no longer good, you have to make it something project specific, like in your case "AdminhelloController.php"

Your URL will then chagne to

Don't forget to adjust the controller classname after renaming or moving the file

Of course you must also adjust any URLs used in menu items and forms that you use in the backend

Also make sure you switch on Developer Mode in the index.php file. I noticed that if the controller has some bug in it, you also get a 404. With Develeport mode you get a Stacktrace error.

What I would also do, is just write a log once the controller is called, just so that you see if the controller method was accessed at all.

class Pulsestorm_Adminhello_Adminhtml_AdminhellobackendController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
Mage::log('Controller was accessed', null, 'controller.log', true);
$this->loadLayout();$this->_title($this->__("My Test Page Title"));$this->renderLayout();
}
}

• can you expand your answer if it works? thanks! – Claudiu Creanga Oct 28 '15 at 18:47
• Ok, done... hope it helps – leedch Oct 30 '15 at 9:15
• Heh, once caught a hilarious Magento developer response back in the day on the old MagentoCommerce forums to your "yet even documenting their code" comment. "But the code is self documenting...". Umm didn't pass the perl pod test then, doesn't now. Thanks for the explanation above, I needed it. – Fiasco Labs Nov 1 '15 at 17:14
• Magento now expects you to move your backend controller classes into a new subfolder called "adminhtml" - this isn't true, the controller can be wherever you want it, it's only under the adminhtml folder in this case because you have defined a starting route of Pulsestorm_Adminhello_Adminhtml in config.xml. You also need to update any admin layout handles, and calls to generates admin URL's like getUrl(). – Jonathan Hussey Nov 3 '15 at 6:16
• @leedch I am pulling my hair out trying to figure out why this module will not work when I change the admin routing for SUPEE-6788 no matter what I try I get a 404 error. It's a simple module to print a custom html invoice. github.com/gaiterjones/magento-htmlinvoice – paj Nov 3 '15 at 13:00

Here's an analysis/fix tool for extension and customization conflicts resulting from the Magento SUPEE-6788 patch.

https://github.com/rhoerr/supee-6788-toolbox

Note: Before applying any patch or patch fix, it is always recommended to make backup of your website and database.

You can only analyze what need to fixed.

To analyze: Run from SSH: php -f fixSUPEE6788.php -- analyze

This will show which files have problems and how you can fix them. This will not apply the fix.

OR, you may apply the changes/fix as well.

To apply changes: Run from SSH: php -f fixSUPEE6788.php -- fix

This will analyze and apply the fix automatically.

• Good Share +1 for u – Amit Bera Dec 7 '15 at 8:16
• Did this but still admin pages for all such modules are showing page 404 – Wasiq Shahrukh May 11 '18 at 12:43