1

I have an invoice id or invoice increment id data, is there a way to load invoice using these?

4

Try this

private $invoice;

public function __construct(
    ....
    \Magento\Sales\Model\Order\Invoice $invoice
) {
    ....
    $this->invoice = $invoice;
}

....
....

// load invoice using entity id
$invoice = $this->invoice->load('1');
// OR
// load invoice using increment id
$invoice = $this->invoice->loadByIncrementId('000000001');

print_r($invoice->getData());
|improve this answer|||||
0

Try this :

public function __construct(
    .....
    \Magento\Sales\Model\Order\Invoice $invoice,
    .......
) {
    ...
    $this->invoice = $invoice;
    ........
    parent::__construct($context, $data);
}


public function getInvoiceDetails($incrementId){

    $invoiceDetails = $this->invoice->loadByIncrementId($incrementId);
    echo "<pre>"; print_r($invoiceDetails->getId()); exit;
 }
|improve this answer|||||

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.