Add module into admin html in Magento - 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>

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.

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'

Magento: what does option "before" do in config.xml file?

I added admin controller.
This code works correct:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mycompany_mymodule>Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
</modules>
</args>
</adminhtml>
</routers>
</admin>
If I add before="Mage_Adminhtml" to mycompany_mymodule:
<mycompany_mymodule before="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
then it doesn't work - got 404 error.
1. What does this option do?
Also I looked throught Alans' Storm article: http://alanstorm.com/magento_admin_controllers
There are example:
<config>
<!-- ... -->
<admin>
<routers>
<the_name_of_this_element_is_not_important_it_should_be_unique>
<use>admin</use>
<args>
<module>Alanstormdotcom_Adminhelloworld</module>
<frontName>adminhelloworld</frontName>
</args>
</the_name_of_this_element_is_not_important_it_should_be_unique>
</routers>
</admin>
<!-- ... -->
</config>
2. What is the difference between these definitions?
It solved:
I found Mage_Core_Controller_Varien_Router_Standard class where collectRoutes() method is defined. It parses "after" and "before" parameters to order the modules.
This method is calling from Mage_Core_Controller_Varien_Router_Admin (started from init method in Mage_Core_Controller_Varien_Front).
So after I looked through match process in Mage_Core_Controller_Varien_Router_Standard.
After Mage_Core_Controller_Varien_Router_Standard debuging I understood my fault.
I used Index controller instead of MyModuleContoller.
Alan Storm defined controller which is not under the admin module (i.e. adminhtml). When I use first config - it works perfect because I defined new modules under the section adminhtml. In Alan's config I cannot add my module to adminhtml. I could override it but it is not correct because other modules under the adminhtml will be removed then.
This is correct code for menu under the adminhtml:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mycompany_mymodule after="Mage_Adminhtml">Mycompany_Mymodule_Adminhtml</mycompany_mymodule >
</modules>
</args>
</adminhtml>
</routers>
</admin>
Inchoo also described this config here.

Magento Overwrite admin template phtml with one from my module

I've gotten quite used to overwriting magento's frontend layout files, so I thought it would be easy to overwrite a phtml template in the admin panel - but I've gotten nowhere in the last six hours. All tutorials I've found so far are concentrating on creating a controller, but I only need to overwrite two phtml files since I only want to change the dispaly of the ordered items a little.
Specifically I want to overwrite the default/template/sales/order/view/items.phtml, normally i'd just match that path in my design folder of my own module and call it a day.
I can overwrite the block php file in Mage/Adminhtml/Sales/Order/View/Items.php through my config.xml:
<config>
...
<global>
...
<blocks>
...
<adminhtml>
<rewrite>
<sales_order_view_items>MyCompany_MyModule_Block_Adminhtml_Sales_Order_View_Items</sales_order_view_items>
</rewrite>
</adminhtml>
</blocks>
...
</global>
...
</config>
How can I tell Magento to use my phtml file in design/adminhtml//default/sales/order/view/items.phtml ?
Shouldn't these lines in my config.xml work?
<config>
...
<adminhtml>
<layout>
<updates>
<my_module>
<file>order_list.xml</file>
</my_module>
</updates>
</layout>
</adminhtml>
...
</config>
Any help is really appreciated! I really hope I've just overlooked something...
What you could do is put your custom module before Mage_Adminhtml
<admin>
<routers>
<adminhtml>
<args>
<modules>
<My_Module before="Mage_Adminhtml">My_Module_Adminhtml</My_Module>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Then copy to your order_list.xml
<adminhtml_sales_order_view>
....
</adminhtml_sales_order_view>
from /app/design/adminhtml/default/default/layout/sales.xml
In order_list.xml you could now replace the block type and template file (phtml) location

Magento: How to override admin controller outside of adminhtml?

Simply put, I want to override ProcessController which is in the Mage/Index/controllers/Admninhtml/ProcessController.php.
I know how to override the front-end controller, but this gives me a headache for hours now. I can't put it to work. Here's my config file
<?xml version="1.0"?>
<config>
<global>
<models>
<twobuy_index>
<class>Twobuy_Index_Model</class>
</twobuy_index>
</models>
</global>
<admin>
<routers>
<index>
<args>
<modules>
<Twobuy before="Mage_Index">Twobuy_Index</Twobuy>
</modules>
</args>
</index>
</routers>
</admin>
</config>
And the controller declaration
include_once('Mage/Index/controllers/Adminhtml/ProcessController.php');
class Twobuy_Index_Adminhtml_ProcessController extends Mage_Index_Adminhtml_ProcessController
{
I tried overriding reindexAction, but my method never gets called.
Replace <index> with <adminhtml> in your config file. It might just be a copy-paste error but your <Twobuy> tag is incorrectly ended with </Ucon>.
<Twobuy before="Mage_Index">Twobuy_Index</Ucon>
Looks like an error in your XML
<twobuy_index before="Mage_Index">Twobuy_Index</twobuy_index>

Resources