views:

73

answers:

1

Hi,

I need to add a new action to the ActionList in the Invoices page
I don't know where magento creates this list and how it call the selected action, so I thought you guys would know where I should start looking...

Thanks!
Jonathan

+2  A: 

The class you want to override is Mage_Adminhtml_Block_Sales_Invoice_Grid. Copy that file into the local space (so you'll have app/code/local/Mage/Adminhtml/Block/Sales/Invoice/Grid.php) and then modify the following function:

protected function _prepareMassaction()
{
    $this->setMassactionIdField('entity_id');
    $this->getMassactionBlock()->setFormFieldName('invoice_ids');

    $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
         'label'=> Mage::helper('sales')->__('PDF Invoices'),
         'url'  => $this->getUrl('*/*/pdfinvoices'),
    ));

    // your action goes here
    $this->getMassactionBlock()->addItem('handle', array(
         'label'=> Mage::helper('sales')->__('Your Action Label'),
         'url'  => $this->getUrl('path/to/your/action'),
    ));  

    return $this;
}

Hope that helps!

Thanks, Joe

Joseph Mastey
Thank you very much! The only small thing on your solution, is that it isn't local dir, but the core folder...
Jonathan
As I said at the beginning of the post, copy the file from the core folder into the local dir. If you modify the core version, it will be overwritten the next time you upgrade the script. In the local folder (or even better, if you override the block with one in your module), you're safer from that problem and can upgrade.
Joseph Mastey