0

I'm working on a MassAction plugin for Sales/Order using Observer. I cant get the controller route to work.

Here is my etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <Test_Compressfiles>
            <version>1.0.0</version>
        </Test_Compressfiles>
    </modules>

    <adminhtml>
        <events>
            <adminhtml_block_html_before>
                <observers>
                    <Test_Compressfiles_Model_Observer>
                        <type>singleton</type>
                        <class>Test_Compressfiles_Model_Observer</class>
                            <method>compressfiles</method>
                    </Test_Compressfiles_Model_Observer>
                </observers>
            </adminhtml_block_html_before>
        </events>             
    </adminhtml>
    <admin>
        <routers>
        <adminhtml>
            <compress>
                <use>admin</use>
                <args>
                    <module>Test_Compressfiles</module>
                    <frontName>compress</frontName>
                </args>
            </compress>
        </adminhtml>
        </routers>
    </admin>

</config>

my folder structure:

- Compressfiles
-- Model / Observer.php
-- Controllers / Adminhtml / Sales/ OrderController.php
-- etc / config.xml

Here is my controller - this is where I dont understand how to get the controller URL:

<?php

require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';

class Test_CompressFiles_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController {


protected function _construct()
{
    Mage::log("COMPRESS");
    die('it works');

}

public function indexAction() {

    Mage::log("COMPRESS");

    echo "test2";

}

public function compressAction() {

    Mage::log("COMPRESS");

    echo "test2";

}

}

?>

1 Answer 1

1

I'm a bit confused why you want your own router, and you're extending an existing controller. If you're just wanting to alter the behavior of Mage_Adminhtml_Sales_OrderController then you'll just want a rewrite router for that controller, like so:

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <test_compressfiles before="Mage_Adminhtml">Test_Compressfiles_Adminhtml</test_compressfiles>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

And I also suggest changing Test_CompressFiles_Sales_OrderController to Test_Compressfiles_Adminhtml_Sales_OrderController and moving it to app\code\local\Test\Compressfiles\controllers\Adminhtml\Sales\OrderController.php

If, on the other hand, you're looking to just create your own controller then I suggest starting with a tutorial like this.

1
  • Thanks, I will try your solution today. PS: I'm trying to make a Mass Action in Sales/Order section that will Compress files of the Orders. Jan 20, 2015 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.