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

adminhtmlce-1.9.2.2custom-admin-urlroutingsupee-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:

localhost/index.php/admin/admin_adminhello/adminhtml_adminhellobackend/index/key/83f08ec4bddff37e47412e16acc8d3f6/

Here's the config of the module:

<config>
    <modules>
        <Pulsestorm_Adminhello>
            <version>0.1.0</version>
        </Pulsestorm_Adminhello>
    </modules>
    <global>
        <helpers>
            <adminhello>
                <class>Pulsestorm_Adminhello_Helper</class>
            </adminhello>
        </helpers>
        <blocks>
            <adminhello>
                <class>Pulsestorm_Adminhello_Block</class>
            </adminhello>
        </blocks>
    </global>
    <admin>
        <routers>
            <adminhello>
                <use>admin</use>
                <args>
                    <module>Pulsestorm_Adminhello</module>
                    <frontName>admin_adminhello</frontName>
                </args>
            </adminhello>
        </routers>
    </admin>
    ...

Here's the controller:

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

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>
    <adminhtml>
        <args>
            <modules>
                <admin_adminhello after="Mage_Adminhtml">Pulsestorm_Adminhello_Adminhtml</admin_adminhello>
            </modules>
        </args>
    </adminhtml>
</routers>

But now the URL just shows 404 error:

localhost/index.php/admin/admin_adminhello/adminhtml_adminhellobackend/index/key/83f08ec4bddff37e47412e16acc8d3f6/

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?

Best Answer

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>
        <adminhello>
            <use>admin</use>
            <args>
                <module>Pulsestorm_Adminhello</module>
                <frontName>admin_adminhello</frontName>
            </args>
        </adminhello>
    </routers>
</admin>

After

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <adminhello before="Mage_Adminhtml">Pulsestorm_Adminhello_Adminhtml</adminhello>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
  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>
    <menu>
        <adminhello_config translate="title" module="adminhello">
            <title>Adminhello Settings</title>
            <sort_order>100</sort_order>
            <children>
                <list_action translate="title" module="adminhello">
                    <title>Manage Hellos</title>
                    <sort_order>4</sort_order>
                <action>adminhello/adminhtml_adminhellobackend</action>
                </list_action>
...
            </children>
        </adminhello_config>
    </menu>
</config>

After

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <adminhello_config translate="title" module="adminhello">
            <title>Adminhello Settings</title>
            <sort_order>100</sort_order>
            <children>
                <list_action translate="title" module="adminhello">
                    <title>Manage Hellos</title>
                    <sort_order>4</sort_order>
                <action>adminhtml/adminhello_adminhellobackend</action>
                </list_action>
...
            </children>
        </adminhello_config>
    </menu>
</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>
...
</adminhello_adminhtml_adminhellobackend_index>

After layout

<adminhtml_adminhello_adminhellobackend_index>
...
</adminhtml_adminhello_adminhellobackend_index>
Related Topic