2

how to get invoice deatils or id by order object ?

$orderObject = Mage::getModel('sales/order')->load($orderId);

Any Method to get invoice_id from above order object ?

2 Answers 2

5

Your code only provides the one invoice which has been created first for this order. But an order may have multiple invoices as Magento is capable of creating multiple partial invoices, then you will have multiple invoice details.

The following code loads all associated invoices:

 $orderObject = Mage::getModel('sales/order')->load($orderId);

 $invoiceCollection = $orderObject->getInvoiceCollection();
 foreach($invoiceCollection as $invoice):
    //var_dump($invoice);
    $invoiceId =  $invoice->getId();
    $invoiceIncrementId =  $invoice->getIncrementId();
 endforeach;
1
  • Yes you are right,I changed my code Commented Dec 20, 2015 at 12:10
3

I got solution to get invoice data from order

 $orderObject = Mage::getModel('sales/order')->load($orderId);

$invoiceIds = $orderObject->getInvoiceCollection()->getAllIds();

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.