2

I want to get the last invoice detail like invoice id invoice pdf file order status.

I tried the following code but no data found.

$orders_invoice = Mage::getModel("sales/order_invoice")->loadByIncrementId($or‌​derIncrementId);
3
  • Please explain your question in detail, what you actually want to do, what you have tried and so on. some code snippet would be great!! Nov 10, 2017 at 8:30
  • I want a create a XML file for ERP when an invoice created so i want the detail of invoice.
    – Piyush
    Nov 10, 2017 at 8:39
  • I used this code $orders_invoice = Mage::getModel("sales/order_invoice")->loadByIncrementId($orderIncrementId); but no data found
    – Piyush
    Nov 10, 2017 at 8:43

1 Answer 1

1

From your question and comment it seems that you want the invoice information from order id, right?

If that is the case, you need to do below:

// $orderId is your order increment id
//Fist load the order model with the order id
$orderObject = Mage::getModel('sales/order')->load($orderId);
//there could be the case of multiple invoices of single order so below will give you all invoices id
$invoiceCollection = $orderObject->getInvoiceCollection();

foreach($invoiceCollection as $invoice):
    //var_dump($invoice);
    $invoiceId =  $invoice->getId();
    $invoiceIncrementId =  $invoice->getIncrementId();
 endforeach;

Now you can load this invoice increament Id to your invoice model to get invoice details.

Hope above answer helps you. If it helps don't forget to accept and vote up the answer.

Regards

2
  • @Piyush Please create a new thread for that and send me the queries link, and I will add those answer there. Nov 10, 2017 at 10:25
  • @Piyush You can use event observer to achieve your further requirement. Nov 10, 2017 at 10:34

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