Magento Admin Controller Issue
-
13-12-2019 - |
Question
On October 22, 2015, Magento will release security patch SUPEE-6788. According to the technical details, 4 APPSEC's that have been fixed require some rework in local and community modules. I'm trying to fix one on my modules but cant seem to get the admin routing working correctly. The extension pages cant be found anymore (404). Here are my files ...
\app\code\community\SolideWebservices\Flexslider\etc\config.xml contains:
<routers>
<adminhtml>
<args>
<modules>
<flexslider after="Mage_Adminhtml">SolideWebservices_Flexslider_Adminhtml</flexslider>
</modules>
</args>
</adminhtml>
</routers>
</admin>
\app\code\community\SolideWebservices\Flexslider\etc\admin.xml contains:
<menu>
<cms>
<children>
<flexslider translate="title" module="flexslider">
<title>Flexslider</title>
<sort_order>100</sort_order>
<children>
<group>
<title>Manage Groups</title>
<sort_order>101</sort_order>
<action>adminhtml/flexslider/group</action>
</group>
<slide>
<title>Manage Slides</title>
<sort_order>102</sort_order>
<action>adminhtml/flexslider/slide</action>
</slide>
</children>
</flexslider>
</children>
</cms>
</menu>
And there are two controllers:
\app\code\community\SolideWebservices\Flexslider\controllers\Adminhtml\GroupController.php
class SolideWebservices_Flexslider_Adminhtml_GroupController extends Mage_Adminhtml_Controller_Action {
protected function _initAction() {
$this->loadLayout();
$this->_setActiveMenu('cms/flexslider');
return $this;
}
public function indexAction() {
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('flexslider/adminhtml_group'));
$this->renderLayout();
} ......
\app\code\community\SolideWebservices\Flexslider\controllers\Adminhtml\SlideController.php
class SolideWebservices_Flexslider_Adminhtml_SlideController extends Mage_Adminhtml_Controller_Action {
protected function _initAction() {
$this->loadLayout();
$this->_setActiveMenu('cms/flexslider');
return $this;
}
public function indexAction() {
$this->_initAction();
$this->renderLayout();
}
protected function _isAllowed() {
return Mage::getSingleton('admin/session')->isAllowed('cms/flexslider/slide');
} ....
What's going on, why is the admin routing not working?
Solution
Ok, I have it working again. This is how I fixed it:
\app\code\community\SolideWebservices\Flexslider\etc\config.xml contains:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<SolideWebservices_Flexslider after="Mage_Adminhtml">SolideWebservices_Flexslider_Adminhtml</SolideWebservices_Flexslider>
</modules>
</args>
</adminhtml>
</routers>
</admin>
\app\code\community\SolideWebservices\Flexslider\etc\admin.xml contains:
<group>
<title>Manage Groups</title>
<sort_order>101</sort_order>
<action>adminhtml/flexslidergroup</action>
</group>
<slide>
<title>Manage Slides</title>
<sort_order>102</sort_order>
<action>adminhtml/flexsliderslide</action>
</slide>
And I renaned the controllers to FlexslidergroupController.php and FlexsliderslideController.php. I could have used "adminhtml/group" and "adminhtml/slide" but as these terms are generic there would be a risk of a conflict so I decided to change the name of the routing URL.
I had to fix some other small stuff as well in the admin layout xml file (located in app/design/adminhtml/defaul/default/layout/custommodule.xml) to reflect the new URL. There where references that had to be updated for instance ... became ... etc.
OTHER TIPS
The patch your talking about was revoked by magento but its good that you are looking at your modules just in case they do release it again.
First in your config.xml
it should be:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<flexslider after="Mage_Adminhtml">SolideWebservices_Flexslider_Adminhtml</flexslider>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Also in your adminhtml.xml
you're declaring the route adminhtml/flexslider/group
so your controller should be \app\code\community\SolideWebservices\Flexslider\controllers\Adminhtml\FlexsliderController.php
with the method of groupAction()
EDIT
In order to have your slider
and group
controller separate you could update your admin.xml
to use the following:
<action>adminhtml/flexslider_group</action>
This should then use \app\code\community\SolideWebservices\Flexslider\controllers\Adminhtml\Flexslider\GroupController.php
and the indexAction()