I'm trying to find a way to print an order's invoice programatically. For that I tried to get the url that Magento uses in backend to print an invoice but it didn't help as it uses a key that I couldn't find a way to retrieve it. I'm now trying another solution, is to code a controller function that renders the invoice pdf :
public function printOrderAction() {
$order_id=json_decode( $this->getRequest()->getParam('order_id'));
$orderObject = Mage::getModel('sales/order')->load($order_id);
$invoiceCollection = $orderObject->getInvoiceCollection();
foreach($invoiceCollection as $inv) {
$invoice = $inv;
}
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
$this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
}
This function, when triggering it, gives that error Not valid template file:frontend\base\default\template\payment/info/pdf/checkmo.phtml
Is there any solution for that error? Or perhaps that there is an other simpler way to get the order's invoice ?