I am adding in a new mass action for the sales order grid and when I am putting in the url for my action Magento cannot find my controller.
config.xml
<admin>
<routers>
<mymodule>
<use>admin</use>
<args>
<module>Namespace_mymodule</module>
<frontName>frontendname</frontName>
</args>
</mymodule>
</routers>
</admin>
<global>
<events>
<adminhtml_block_html_before>
<observers>
<mymodule>
<class>Namespace_mymodule_Model_Observer</class>
<method>addActions</method>
</mymodule>
</observers>
</adminhtml_block_html_before>
</events>
</global>
observer.php
public function addActions($event)
{
$block = $event->getBlock();
if($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid)
{
$block->getMassactionBlock()->addItem('cpsync', array(
'label' => 'Push Orders to CounterPoint',
'url' => Mage::helper("adminhtml")->getUrl("frontendname/adminhtml_index/push/")
));
}
}
Whenever I try to use my mass action it sends me to a 404 redirect page with url
sitename.com/index.php/frontendname/adminhtml_index/push/key/
I think your config.xml is wrong. In the above config.xml, you havent mentioned about the model, block or helper classes. You had just declared about the module and an event. Here is the basic config.xml that you have to follow. Try to modify your config.xml as below.
<?xml version="1.0"?>
<config>
<modules>
<Test_Helloworld>
<version>0.1.0</version>
</Test_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Test_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
<layout>
<updates>
<helloworld>
<file>helloworld.xml</file>
</helloworld>
</updates>
</layout>
</frontend>
<global>
<blocks>
<helloworld>
<class>Test_Helloworld_Block</class>
</helloworld>
</blocks>
<helpers>
<helloworld>
<class>Test_Helloworld_Helper</class>
</helloworld>
</helpers>
</global>
</config>
Related
Im kinda stuck in my development. Im trying to add a new mass action to the adminpanel for orders, but i always return 404. I have tried multiple methods but never succeeded.. Hope some of you can tell me what i am doing wrong and how to fix it.
My config.xml
<modules>
<plusshop_shipmentcontrol>
<version>0.1.0</version>
</plusshop_shipmentcontrol>
</modules>
<global>
<models>
<shipmentcontrol>
<class>Plusshop_ShipmentControl_Model</class>
</shipmentcontrol>
</models>
</global>
<admin>
<routers>
<shipmentcontrol>
<use>admin</use>
<args>
<module>Plusshop_ShipmentControl</module>
<frontName>shipmentcontrol</frontName>
</args>
</shipmentcontrol>
</routers>
</admin>
<adminhtml>
<events>
<!-- Before rendering event -->
<core_block_abstract_prepare_layout_before>
<observers>
<plusshop_shipmentcontrol_add>
<type>singleton</type>
<class>shipmentcontrol/observer</class>
<method>addMassExport</method>
</plusshop_shipmentcontrol_add>
</observers>
</core_block_abstract_prepare_layout_before>
</events>
</adminhtml>
My Model/Observer.php:
<?php
class Plusshop_ShipmentControl_Model_Observer
{
public function addMassExport(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
if($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction && $block->getRequest()->getControllerName() == 'sales_order')
{
$block->addItem('shipmentcontrolall', array(
'label' => 'Create all shipments (GLS, DAO)',
'url' => Mage::app()->getStore()->getUrl('*/shipmentcontrol/massactions/index')
));
}
}
}
And finally my MassActionsController.php
<?php
require_once 'Mage/Adminhtml/controllers/Action.php';
class Plusshop_ShipmentControl_MassActionsController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
// $orderIds = $this->getRequest()->getPost('order_ids', array());
$this->_redirect('adminhtml/sales_order/');
}
}
Really hope some of you can tell what im doing wrong here? Feel like i tried everything but no luck. Did i misunderstood something or what is wrong?
Regards
Kevin.
Replace:
<admin>
<routers>
<shipmentcontrol>
<use>admin</use>
<args>
<module>Plusshop_ShipmentControl</module>
<frontName>shipmentcontrol</frontName>
</args>
</shipmentcontrol>
</routers>
</admin>
with:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Plusshop_ShipmentControl after="Mage_Adminhtml">Plusshop_ShipmentControl</Plusshop_ShipmentControl>
</modules>
</args>
</adminhtml>
</routers>
</admin>
You should be able to visit your page at: yoururl.com/admin/massactions/index (replace /admin part if you use different path to admin).
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>
I created a button on my Adminhtml_Sales_Order_View file and i want it to point to my admin html controller but for an unknown reason when i click the button i got a page 404 error in the front end.
this is my /etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<PixelPlusOne_DragonPay>
<version>1.0.0</version>
</PixelPlusOne_DragonPay>>
</modules>
<global>
<models>
<dragonpay>
<class>PixelPlusOne_DragonPay_Model</class>
</dragonpay>
</models>
<helpers>
<dragonpay>
<class>PixelPlusOne_DragonPay_Helper</class>
</dragonpay>
</helpers>
<blocks>
<dragonpay>
<class>PixelPlusOne_DragonPay_Block</class>
</dragonpay>
</blocks>
</global>
<default>
<payment>
<dragonpay>
<model>dragonpay/standard</model>
<active>1</active>
<order_status>pending</order_status>
<title>Dragon Pay</title>
<payment_action>sale</payment_action>
<allowspecific>0</allowspecific>
<sort_order>1</sort_order>
</dragonpay>
</payment>
</default>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<PixelPlusOne_DragonPay before="Mage_Adminhtml">PixelPlusOne_DragonPay_Adminhtml</PixelPlusOne_DragonPay>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<frontend>
<routers>
<dragonpay>
<use>standard</use>
<args>
<module>PixelPlusOne_DragonPay</module>
</args>
</dragonpay>
</routers>
</frontend>
</config>
This is the button i added to my Sales_Order_View
/* UPDATE INCLUDED BY DRAGONPAY PAYMENT MODULE - START */
/**
* This button is added for DragonPay for QUERY API button for manual checking of payment result
*/
if($order->getPayment()->getMethodInstance()->getCode() == 'dragonpay'){
$message = 'Query the Payment Gateway To Check If Any Payments Made?';
$url = Mage::helper('adminhtml')->getUrl('dragonpay/adminhtml_admindragonpay/query/',array('order_id'=>$order->getId()));
$this->addButton('dragonpayapi_query', array(
'label' => '[--DRAGONPAY:Get payment status--]',
'onclick' => "confirmSetLocation('{$message}', '{$url}')",
));
}
/* UPDATE INCLUDED BY DRAGONPAY PAYMENT MODULE - END *
and finally my Adminhtml Controller
<?php
class PixelPlusOne_DragonPay_Adminhtml_AdmindragonpayController extends Mage_Adminhtml_Controller_Action
{
public function queryAction(){
echo "hi";
}
}
?>
Hoping that anybody could help me and i really appreciate the help. Thanks in advance.
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>
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