I got this code:
public function loadInvoice($invoiceno)
if ($invoiceno instanceof Mage_Sales_Model_Order_Invoice) {
$invoice = $invoiceno;
}
else {
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceno);
}
$ordernumber = 0;
$invoice_collection = $invoice->getOrder()->getInvoiceCollection()->getItems();
if (count($invoice_collection) > 1) {
$count = 0;
foreach ($invoice_collection as $key => $value) {
$count++;
if ($value->getIncrementId() == $invoice->getIncrementId()) {
if ($count == 1) {
$ordernumber = $invoice->getOrder()->getIncrementId();
}
else {
$ordernumber = $invoice->getOrder()->getIncrementId().'_'.$count;
}
break;
}
}
}
if (!$ordernumber) {
$ordernumber = $invoice->getOrder()->getIncrementId();
}
And I want to export the order number, instead of the invoice number.