0

I`m fetching invoice collection using Mage::getModel('sales/order_invoice')->getCollection(); but I also want Order number, payment method and customer name according to the invoice number. How to fetch that and display in grid?

0

Please find the below answer to get order number,order information,payment method and customer name based on invoice id --

<?php
require_once('./app/Mage.php');
Mage::app();

$invoiceid =15;

/* get invoice collection  */
$invoicecollection = Mage::getModel("sales/order_invoice")->getCollection()
                                                        ->addFieldToFilter('entity_id',$invoiceid)
                                                        ->getData();

/* get order number and collection with customer name */
$orderId = $invoicecollection[0]['order_id'];
$order = Mage::getModel('sales/order')->load($orderId);

//echo "<pre>"; print_r($order->getData());
echo $order->getCustomerFirstname();

/* get payment information and card type */
$payment = $order->getPayment();
//echo "<pre>"; print_r($payment->getData());
echo $payment['cc_type'];

//Get Payment Info
echo $payment->getMethodInstance()->getCode();
echo $payment->getMethodInstance()->getTitle(); 

?>
  • This might be correct but what I`m looking is for to fetch the order number, customer name and payment method according to invoice number on admin panel grid! – Darshan Jethwa Jun 26 '18 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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