0

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.

0

Answer is to change invoice_collection to order.

Then it will export right.

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.