0

I manage to get the order id but not the order number

$invoicesCollection = $this->_invoiceCollectionFactory->create()->addFieldToSelect(array('*'));
$invoices = $invoicesCollection->getItems();
foreach($invoices as $invoice){
    $orderId = $invoice->getOrderId();
}
0

Try this:

$invoicesCollection = $this->_invoiceCollectionFactory->create()->addFieldToSelect(array('*'));
$invoices = $invoicesCollection->getItems();
foreach($invoices as $invoice){
    $orderId = $invoice->getOrder()->getIncrementId();
}
1
  • thanks but the invoice object doesn't have getOrder() i get an error – open-ecommerce.org Oct 23 '18 at 23:28
0

I try many hours to get the order number from the Invoice object but I can only get the OrderId so i added the order collection factory:

        $ordersCollection = $this->_orderCollectionFactory->create()->addFieldToSelect(array('*'))
            ->addFieldToFilter('entity_id', $invoice->getOrderId());
        $order = $ordersCollection->getData();
        $orderNumber = $order[0]["increment_id"];

And it is working fine

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.