0

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/

asked Feb 7, 2014 at 3:48
1
  • My Better404 module (free, opens source) can help you track down 404 page related issues. alanstorm.com/magento-404-debug Commented May 9, 2014 at 17:31

1 Answer 1

1

Try the following

if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
 && $block->getRequest()->getControllerName() == 'sales/order')
 {
 $block->addItem('cpsync', array(
 'label' => 'Push Orders to CounterPoint',
 'url' => Mage::app()->getStore()->getUrl('*/yourcontroller/youraction'),
 ));
 }

If your controller file's name is something like CpsyncController.php, it would need a method like public function pushAction(){<!--your code here-->}, the */yourcontroller/youraction bit in your Observer would be */cpsync/push

P.S it is imperative that you use the Action suffix after the method name in your controller for the redirect to pick up the function itself.

answered Feb 7, 2014 at 6:08
1
  • still getting the same url with the 404 redirect. its in a folder called adminhtml in controllers and then IndexController.php would the url be */adminhtml_index/push? Commented Feb 7, 2014 at 16:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.