34

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?

42

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>
  • Excellent! Worked like a charm! – BENN1TH Mar 25 '16 at 8:12
17

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

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

app/code/local/Pulsestorm/Adminhello/controllers/Adminhtml

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

http://localhost/index.php/admin/adminhellobackend/index/key/83f08ec4bddff37e47412e16acc8d3f6/

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

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

In this case the name would be Pulsestorm_Adminhello_Adminhtml_AdminhellobackendController

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.

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

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
  • 3
    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
8

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

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.