I wish to print invoices using HTML, so have added a 'Print A4 Label' mass action, by copying app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php to app/code/local/Mage/Adminhtml/Block/Sales/Invoice/Grid.php and added the following code:
$this->getMassactionBlock()->addItem('printa4label', array(
'label'=> Mage::helper('sales')->__('Print A4 Label'),
'url' => $this->getUrl('*/sales_invoice/printa4label'),
));
This has added a mass action option that points to index.php/admin/sales_invoice/printa4label/key/... which currently gets a 404 error.
What file/directory do I need to create to handle this new mass action, and how do I handle the data that is sent?
Update
app/code/local/GCT/Printlabel/etc/config.xml
<?xml version="1.0"?>
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<GCT_Printlabel before="Mage_Adminhtml">GCT_Printlabel_Adminhtml</GCT_Printlabel>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
app/code/local/GCT/Printlabel/controllers/Adminhtml/Sales/Order/InvoiceController.php
<?php
require_once 'Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php';
class GCT_Printlabel_Adminhtml_Sales_Order_InvoiceController extends Mage_Adminhtml_Sales_Order_InvoiceController
{
public function printlabelAction()
{
echo "Hello World";
exit;
}
}
app/etc/modules/GCT_Printlabel.xml
<?xml version="1.0"?>
<config>
<modules>
<GCT_Printlabel>
<active>true</active>
<codePool>local</codePool>
</GCT_Printlabel>
</modules>
</config>
app/code/local/Mage/Adminhtml/Block/Sales/Invoice/Grid.php
...
$this->getMassactionBlock()->addItem('printlabel', array(
'label'=> Mage::helper('sales')->__('Print Label'),
'url' => $this->getUrl('*/sales_invoice/printlabel'),
));
...
I am still getting the 404 error.