0
votes

I can add buttons to Magento admin grids and have that action call some admin controller action. This all works fine with my own modules where the syntax for the action is */*/action, that will call admin code from the same module no problem

However, I want to add a button to the product admin grid and have it call some adminhtml action in my own module.

Adding the button is no problem, but to get it to call the admin controller actions in my own module is not working for me. I can get the button to call a frontend action of my own module with mymodule/index/action, but adminhtml actions aren't working out so easy.

Does anyone have an example of how to do this to share?

1
Share your module's router config admin/routers? Also, how are you generating URLs? - benmarks
@benmarks is correct very hard to provide help without seeing any code... - Gershon Herczeg

1 Answers

2
votes

This code works for me:

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <module before="Mage_Adminhtml">Something_Adminhtml</module>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

$this->_addButton('module_controller', array(
        'label' => $this->__('Something Action'),
        'onclick' => "setLocation('{$this->getUrl('*/module/anyaction')}')",
    ));