0

Payments method are visible in backend-printed invoices, but on custom front-end function field payment is blank, any suggestions?

No templete files were edited.

Controller responsible of printing invoices:

public function downloadPdfAction()
{
    $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
    if ($invoiceId) {
        $invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
        $order = $invoice->getOrder();
    } else {
        $orderId = (int) $this->getRequest()->getParam('order_id');
        $order = Mage::getModel('sales/order')->load($orderId);
    }

    if ($this->_canViewOrder($order)) {

        Mage::register('current_order', $order);
        if (isset($invoice)) {
            Mage::register('current_invoice', $invoice);
            $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
        } else {
            $invoices = $order->getInvoiceCollection();
            $invoicesSet = array();
            foreach ($invoices as $_invoice) {
                array_push($invoicesSet, $_invoice);
            }

            $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoicesSet);
        }

        $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
            '.pdf', $pdf->render(), 'application/pdf');
    } else {
        if (Mage::getSingleton('customer/session')->isLoggedIn()) {
            $this->_redirect('*/*/history');
        } else {
            $this->_redirect('sales/guest/form');
        }
    }
}

Thanks for help.

2 Answers 2

1

try following function to fetch payment method title

$order->getPayment()->getMethodInstance()->getTitle();

2
  • i've put $order->getPayment()->getMethodInstance()->getTitle(); as first line inside $this->_canViewOrder block, no result. Same for $invoice->getOrder()->getPayment()->getMethodInstance()->getTitle() var_dump of these result in correct payment name
    – Lukasz
    Oct 16, 2015 at 6:10
  • Worked for me, +1
    – hellimac
    Jan 4, 2016 at 4:13
0

I've faced the same issue. I'm using this code.

if ($invoice = Mage::getModel('sales/order_invoice')->load($invoiceIds[0])) {
            $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
            $pdf->render();
            $pdf->save(Mage::getBaseDir(). DS . "var". DS. "email_invoice". DS .$this->getIncrementId()."-invoice.pdf");

}

Payment method section is blank when pdf generating. Any thought?

Thanks in advance.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.