Magento get order invoice id and order items

<?php
        $orderId = '1234567890';
        $order  = Mage::getModel('sales/order')->load($orderId);
 
        if ($order->hasInvoices()) {
        $invoiceIds = $order->getInvoiceCollection()->getAllIds();
        $invoiceId = $invoiceIds[0];
        echo 'invoiceId: '.$invoiceId."\n";
        }
 
        foreach ($order->getAllItems() as $item) {
        echo $item->getId().'->'.$item->getQtyOrdered()."\n";
        }

Leave a Reply