magento controller not found - magento

I have set up a controller in my module to add an order export tab to my installation:
in config.xml:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orderexport>abc_Orderexport_index2</orderexport>
</modules>
</args>
</adminhtml>
</routers>
<layout>
<updates>
<orderexport>
<file>orderexport.xml</file>
</orderexport>
</updates>
</layout>
</admin>
in adminhtml.xml:
<?xml version="1.0"?>
<config>
<menu>
<sales>
<children>
<orderexport>
<title>Order Export</title>
<sort_order>20</sort_order>
<action>adminhtml/index2</action>
</orderexport>
</children>
</sales>
</menu>
<acl>
<resources>
<admin>
<children>
<sales>
<children>
<orderexport>
<title>Order Export</title>
<sort_order>20</sort_order>
</orderexport>
</children>
</sales>
</children>
</admin>
</resources>
</acl>
</config>
and in the controllers/Adminhtml/Index2Controller.php file
class abc_Orderexport_Adminhtml_Index2Controller extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
However with all this done, whenever I click on the button "Order Export" it redirects me to the 404 page. That means that Magento cannot find the controller but idk why.
When i rename the controller everywhere from index2 into index (Index2Controller.php to IndexController.php) I am not getting redirected to the 404 page, HOWEVER the Dashboard of the admin panel just reloads.
I really don't know where my error is and Im happy for any hints into the right direction.

Here is what you have to fix:
in config.xml: you have to say that your module should be use in the adminhtml area, and you have to respect the CamelCase, here is how it should look like:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Abc_Orderexport after="Mage_Adminhtml">Abc_Orderexport_Adminhtml</Abc_Orderexport>
</modules>
</args>
</adminhtml>
</routers>
</admin>
in your controller, again, you must respect CamelCase, i.e. the class name is Abc_Orderexport_Adminhtml_Index2Controller
All this is assuming your folder structure is:
app/
code/
local/
Abc/
Orderexport/
controllers/
Adminhtml/
Index2Controller.php
etc/
config.xml
adminhtml.xml
, exactly, upper/lower case is important

Could you please try the following code and make sure that you module class name and folder structure must be in standard magento
extension structure. config.xml
<admin>
<routers>
<orderexport>
<use>admin</use>
<args>
<modules>
<orderexport>Abc_Orderexport_Index2</orderexport>
<frontName>orderexport</frontName>
</modules>
</args>
<orderexport>
</routers>
<layout>
<updates>
<orderexport>
<file>orderexport.xml</file>
</orderexport>
</updates>
</layout>
</admin>

Related

Magento 1.9 add layout and template to custom module in admin

I try to create custom module that shows on main page two tabs with option to change titles, backgrounds, colors.
I successfully add the module tab in admin and can't add layout and template.
I'm stuck.
Can any one explain, please, how I can do this?
Here are the xml files that I got:
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Lern_Sample>
<version>0.1.0</version>
</Lern_Sample>
</modules>
<frontend>
<routers>
<sample>
<use>standard</use>
<args>
<module>Lern_Sample</module>
<frontName>sample</frontName>
</args>
</sample>
</routers>
</frontend>
<admin>
<routers>
<sample>
<use>admin</use>
<args>
<module>Lern_Sample</module>
<frontName>admin_sample</frontName>
</args>
</sample>
</routers>
</admin>
<global>
<helpers>
<sample>
<class>Lern_Sample_Helper</class>
</sample>
</helpers>
</global>
<adminhtml>
<menu>
<sample module="sample">
<title>Sample Module</title>
<sort_order>100</sort_order>
<children>
<sample module="sample">
<title>Sample Module</title>
<sort_order>0</sort_order>
<action>admin_sample/adminhtml_index</action>
<layout>
<lern_sample>
<file>lern_sample.xml</file>
</lern_sample>
</layout>
</sample>
</children>
</sample>
</menu>
</adminhtml>
module xml etc/Lern_Sample.xml
<?xml version="1.0"?>
<config>
<modules>
<Lern_Sample>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Adminhtml />
</depends>
</Lern_Sample>
</modules>
You can add your own layout file by declaring it under the node <frontend>, just like this :
<layout>
<updates>
<sample>
<file>sample.xml</file>
</sample>
</updates>
</layout>
Your layout file will have to be located under app/design/frontend/MY_CUSTOM_PACKAGE/MY_DEFAULT_THEME/layout/sample.xml or under the base installation app/design/frontend/base/default/layout/sample.xml
If you try to add a layout update file for the admin, just use this code sample under the node <adminhtml>.

I am Having issues when adding menu in admin panel magento

I 've made a file to add my module as: [ File as- Axovel_MenuItem.xml]
<?xml version="1.0"?>
<config>
<modules>
<Axovel_MenuItem>
<active>true</active>
<codePool>local</codePool>
</Axovel_MenuItem>
</modules>
</config>
in folder app/etc/modules/
then i made a configuration file(config.xml) as
<?xml version="1.0"?>
<config>
<modules>
<Axovel_MenuItem>
<version>0.1.0</version>
</Axovel_MenuItem>
</modules>
<global>
<helpers>
<menuitem>
<class>Axovel_MenuItem_Helper</class>
</menuitem>
</helpers>
</global>
<frontend>
<routers>
<menuitem>
<routeurfrontend>
<use>standard</use>
<args>
<module>Axovel_MenuItem</module>
<frontName>menuitem</frontName>
</args>
</routeurfrontend>
</menuitem>
</routers>
</frontend>
<adminhtml>
<layout>
<updates>
<menuitem>
<file>menuitem.xml</file>
</menuitem>
</updates>
</layout>
<acl>
<resources>
<admin>
<children>
<menuitem>
<title>Awesome Menu Item</title>
<children>
<sub_menu1>
<title>Example Menu Item</title>
</sub_menu1>
</children>
</menuitem>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
in folder app/code/local/Axovel/MenuItem/etc/
then i made a Adminhtml Configuration File(adminhtml.xml) as
<?xml version="1.0"?>
<config>
<menu>
<menuitem>
<title>Awesome Menu Item</title>
<sort_order>20</sort_order>
<children>
<sub_menu1>
<title>Example Menu Item</title>
<sort_order>0</sort_order>
<!-- <action>menuitem/index/index</action> -->
</sub_menu1>
</children>
</menuitem>
</menu>
</config>
in folder app/code/local/Axovel/MenuItem/etc/
and made a Helper File(Data.php) as:
<?php
class Axovel_MenuItem_Helper_Data extends Mage_Core_Helper_Abstract
{
}
?>
in folder app/code/local/Axovel/MenuItem/Helper/
I also made a Controller file(IndexController.php) as:
<?php
class Axovel_MenuItem_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
But Not Getting the Desired Results, I am not able to see my custom menu Item
Even i am not able to call my indexController/indexAction directly with Hyperlink as
http://127.0.0.1/magento/index.php/menuitem/index/index
there is something Wrong in config.xml but i am not able to figure it out, can anyone please Help?
Thanks :)
This looks like it is probably a caching issue. If you are new to magento, the cache can be easy to forget and really cause some problems for you. You should try clearing that in the backend or from the command line. cache is found in the var folder and you will want to empty bother the cache folder and the full_page_cache folder.
I don't know if the menu button will work or not because you didn't give any code that would generate a new page or block.

Access Denied error when accessing catalog_product from custom module and logged in from other than admin

I have created a custom module, in the module when I click Save button sends request to catalog_products save function and save data to my extension's tables only(I have changed core file for this). Url on which I send request is:
localhost/magento/index.php/admin/admin/catalog_product/save/id/71/key5QDhzOH0ZRIgYZIC/?form_key=5QDhzOH0ZRIgYZIC&from_bpstore=yes
I have used ajax to save my data. And it is saving data when logged in from user having role "Administrator" but as I log in from any other user then it gives "Access Denied" error in response. Following is my config.xml for custom module:
<?xml version="1.0"?>
<config>
<modules>
<Bp_BpstoreInfo>
<version>0.1.0</version>
</Bp_BpstoreInfo>
</modules>
<global>
<helpers>
<bpstoreinfo>
<class>Bp_BpstoreInfo_Helper</class>
</bpstoreinfo>
</helpers>
<blocks>
<bpstoreinfo>
<class>Bp_BpstoreInfo_Block</class>
</bpstoreinfo>
</blocks>
</global>
<admin>
<routers>
<bpstoreinfo>
<use>admin</use>
<args>
<module>Bp_BpstoreInfo</module>
<frontName>bpstoreinfo</frontName>
</args>
</bpstoreinfo>
</routers>
</admin>
<adminhtml>
<menu>
<bpstoreinfo module="bpstoreinfo">
<title>Room Prices</title>
<sort_order>77</sort_order>
<action>bpstoreinfo/adminhtml_bpstoreinfobackend</action>
</bpstoreinfo>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<bpstoreinfo>
<title>bpstoreinfo Module</title>
<sort_order>1</sort_order>
</bpstoreinfo>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<bpstoreinfo>
<file>bpstoreinfo.xml</file>
</bpstoreinfo>
</updates>
</layout>
</adminhtml>
</config>
And my controller of custom module is
<?php
class Bp_BpstoreInfo_Adminhtml_BpstoreinfobackendController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->_title($this->__("Booking Prices"));
$this->renderLayout();
}
}
But when Ajax runs it sends data to catalog product module, Is this the problem that I am not able to save my data.
Please help I am totally stuck here. Thanks in Advance.

override orders controller in magento

I have a custom module Permissions_Orders. Here is my code to override orders controller from base admin -
config.xml -
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orders before="Mage_Adminhtml">Orders_Adminhtml_Sales_OrderController</orders>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Permissions/Orders/controllers/Adminhtml/Sales/OrderController.php -
<?php
require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
class Permissions_Orders_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
{
----
}
but still it is calling from base controller. I am not sure, where I am wrong here. Any help is appreciated.
Your config.xml should look like below,
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<orders before="Mage_Adminhtml">Permissions_Orders_Adminhtml</orders>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Notice the change in </orders> node.
In config.xml is enough to specify the namespace and module name where you want to extend the base adminhtml controllers.
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Namespace_Adminhtml before="Mage_Adminhtml">Namespace_Adminhtml</Namespace_Adminhtml>
</modules>
</args>
</adminhtml>
</routers>
</admin>

Admin controller not working in Magento

I've used a yeoman generator to build a Magento Module skeleton.
I can access the frontend module simply with:
http://prueba.com/index.php/prueba/index
But I can't make it work the admin. These are my files:
/etc/adminhtml.xml
<config>
<menu>
<prueba>
<title>My Tab</title>
<sort_order>1</sort_order>
<action>adminhtml/prueba/index</action>
</prueba>
</menu>
</config>
/controllers/adminhtml/IndexController.php
<?php
/**
* Index Adminhtml Controller
*
*/
class Altimea_Prueba_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
/**
* Index Action
*/
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
echo 'hello';
}
}
/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Altimea_Prueba>
<version>0.1.0</version>
</Altimea_Prueba>
</modules>
<global>
<models>
<altimeaprueba>
<class>Altimea_Prueba_Model</class>
</altimeaprueba>
</models>
<blocks>
<altimeaprueba>
<class>Altimea_Prueba_Block</class>
</altimeaprueba>
</blocks>
<helpers>
<altimeaprueba>
<class>Altimea_Prueba_Helper</class>
</altimeaprueba>
</helpers>
<resources>
<altimeaprueba_setup>
<setup>
<module>Altimea_Prueba</module>
<class>Altimea_Prueba_Model_Resource_Setup</class>
</setup>
</altimeaprueba_setup>
</resources>
</global>
<frontend>
<layout>
<updates>
<altimeaprueba>
<file>altimeaprueba.xml</file>
</altimeaprueba>
</updates>
</layout>
<routers>
<altimeaprueba>
<use>standard</use>
<args>
<module>Altimea_Prueba</module>
<frontName>prueba</frontName>
</args>
</altimeaprueba>
</routers>
</frontend>
<adminhtml>
<layout>
<updates>
<altimeaprueba>
<file>altimeaprueba.xml</file>
</altimeaprueba>
</updates>
</layout>
</adminhtml>
<admin>
<routers>
<altimeaprueba>
<use>admin</use>
<args>
<module>Altimea_Prueba</module>
<frontName>prueba</frontName>
</args>
</altimeaprueba>
</routers>
</admin>
</config>
When create a magento admin module you can create it in one of two ways. Since you have both a front and backend controller try changing your admin route to <frontname>admin_prueba</frontname> then try http://prueba.com/index.php/admin_prueba/index
<adminhtml>
<menu>
<menu1 translate="title" module="customlist">
<title>ActiveCodeline SampleModule1</title>
<sort_order>60</sort_order>
<children>
<menuitem1 module="SampleModule1">
<title>Menu item 1</title>
<action>{{customlist}}/index</action>
</menuitem1>
<admin>
<routers>
<samplemodule1>
<use>admin</use>
<args>
<module>ActiveCodeline_SampleModule1</module>
<frontname>admin_customlist</frontname>
</args>
</samplemodule1>
</routers>
</admin>
or
<adminhtml>
<menu>
<menu1 translate="title" module="customlist">
<title>ActiveCodeline SampleModule1</title>
<sort_order>60</sort_order>
<children>
<menuitem1 module="SampleModule1">
<title>Menu item 1</title>
<action>{{adminhtml/customlist}}/index</action>
</menuitem1>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Company_CustomList before="Mage_Adminhtml">Foo_Bar_Adminhtml</Company_CustomList>
</modules>
</args>
</adminhtml>
</routers>
</admin>
You have missed to add this in config.xml
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<altimea_prueba after="Mage_Adminhtml">Altimea_Prueba_Adminhtml</altimea_prueba>
</modules>
</args>
</adminhtml>
</routers>
</admin>
In config.xml, change this:
<admin>
<routers>
<altimeaprueba>
<use>admin</use>
<args>
<module>Altimea_Prueba</module>
<frontName>prueba</frontName>
</args>
</altimeaprueba>
</routers>
</admin>
To this:
<admin>
<routers>
<altimea_prueba>
<use>admin</use>
<args>
<module>Altimea_Prueba</module>
<frontName>prueba</frontName>
</args>
</altimea_prueba>
</routers>
</admin>
If you want to see your "hello" printed out, in IndexController.php, add exit(); after your echo "hello";
Just a reference
It took me ages to figure out that
<args>
<modules>
<myrandomtag before="Mage_Adminhtml">
My_Module_Adminhtml
</myrandomtag>
</modules>
</args>
IS NOT SAME AS
<args>
<modules>
<myrandomtag before="Mage_Adminhtml">My_Module_Adminhtml</myrandomtag>
</modules>
</args>
So there should be no space or new line inside your random tag

Resources