Magento Forum

   
Adding MassAction to Sales Order (I cant seem to get it to work)
 
seansan
Member
 
Total Posts:  62
Joined:  2010-01-27
 

Hi, I am looking at creating a new MassAction action ‘shipmailinvoice’. Some hours of debugging and I cant seem to find the error. Status: the dropdown element was added, but now when I select it and submit I receive a 404 error, cannot find page.

Current problem

Where should I save OrderController.php for Magento to find it? (now in 3 places wink) I keep getting 404 error.

Maybe someone with a fresh view can spot it

config.xml to define module

<?xml version="1.0"?>
<config>
    <
modules>
        <
SNH_ShipMailInvoice>
            <
version>0.1.0</version>
        </
SNH_ShipMailInvoice>
    </
modules>
    <global>
     
    <
events>
        <
core_block_abstract_prepare_layout_before>
            <
observers>
                <
newmodule_core_block_abstract_prepare_layout_before>
                    <class>
SNH_ShipMailInvoice_Model_Observer</class>
                    <
method>addActions</method>
                </
newmodule_core_block_abstract_prepare_layout_before>
            </
observers>
        </
core_block_abstract_prepare_layout_before>
    </
events>
   
    </global>
   
    <
admin>
        <
routers>
            <
adminhtml>
                <
args>
                  <
modules>
                    <
SNH_ShipMailInvoice before="Mage_Adminhtml">SNH_ShipMailInvoice</SNH_ShipMailInvoice>
                  </
modules>
                </
args>
            </
adminhtml>
        </
routers>
    </
admin>
</
config>

Observer.php to add dropdown element

<?php
class SNH_ShipMailInvoice_Model_Observer
{
    
public function addActions($observer)
    
{
        $block 
$observer->getEvent()->getBlock();
        
// Check if this block is a MassAction block
        
if ($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction{
            
// Check if we're dealing with the Orders grid
            
if ($block->getParentBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Grid{
                
// The first parameter has to be unique, or you'll overwrite the old action.
                
$block->addItem('shipmailinvoice', array(
                        
'label' => Mage::helper('sales')->__('Ship, Mail and Invoice'),
                        
'url' => $block->getUrl('*/sales_order/shipmailinvoice'),
                    )
                );
            
}
        }
    }
}

edit. Also tried ‘url’ => $block->getUrl(’*/*/shipmailinvoice’),

OrderController.php, looks like it is not being found

<?php
/**
* Adminhtml sales orders controller extension
*
* @author      Magento Core Team <core@magentocommerce.com>
*/

class SNH_ShipMailInvoice_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
{

    
public function shipmailinvoiceAction(){

    
try {
        
// SNH 26.1.12 And return to main page
        
$url "http://google.com";
        
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
    
catch (Exception $e{
        $this
->_getSession()->addError($this->__('Not working. TEST'))
        
Mage::logException($e)
        
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
    
}

    }


}

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top