1

It is driving me crazy. What I want to do is creating a new Action in the controller:

Mage/Adminhtml/controllers/Sales/OrderController.php

I have done the rewrite using that:

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <mymodule_resetdownloads before="Mage_Adminhtml">Mymodule_Resetdownloads_Adminhtml</mymodule_resetdownloads>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

and the class is:

require_once (Mage::getModuleDir('controllers','Mage_Adminhtml').DS.'Sales/OrderController.php');
class Mymodule_Resetdownloads_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
{

    public function resetAction() {

        $id = $this->getRequest()->getParam('id');
        $this->loadLayout();
        $this->renderLayout();
        echo $id;
    }


}

Now the rewrite works and I know that because if I create another action like viewAction() it uses mine. But my problem is that I can't create a new one. Any idea why? Am I doing something wrong. I am not getting any error from what I have done, it just redirects me to dashboard.

  • what url is being called for the reset action? – David Manners Jul 25 '14 at 11:48
  • <a href="<?php echo $this->getBaseUrl().'admin/sales_order/reset/id/'.$_link->getId(); ?>">Reset Downloads</a> – vbak Jul 25 '14 at 12:09
  • Your link should be Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/reset", array('id'=> $_link->getId())) – Renon Stewart Jul 25 '14 at 19:52
1

The issue seem to be with your url key, try adding this to your controller (then go to Admin -> Sales -> Order and click on any order #)

To get the admin url use

Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/mytest", array('id'=> 1));

Try

public function mytestAction(){
    echo 'mytestAction()';
}

//
//to be deleted
public function viewAction(){
   echo '<a href ="' . Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/mytest", array('order_id'=> 1)) .'">mytest action</a>';
}
  • Thanks my friend! My bad! The way I was making the link was wrong. – vbak Jul 27 '14 at 8:34
0

you need to make your controller extend the original controller: Mage_Adminhtml_Sales_OrderController instead of Mage_Adminhtml_Controller_Action

0

Try:

 <modules>
                        <Mymodule_Resetdownloads before="Mage_Adminhtml">Mymodule_Resetdownloads_Adminhtml</Mymodule_Resetdownloads>
                    </modules>
  • As I said in my question the controller is overrode correctly and if I use the original Actions like viewActions it is using mine.The problem is that I can't create a new Action ! PS I did try that.Still the same.Thanks! – vbak Jul 25 '14 at 11:37

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.