Get Invoice data by invoice id Magento 2.

You can get full details of Invoice related data using invoice id in Magento 2.

Using Magento\Sales\Api\InvoiceRepositoryInterface class you can get details of invoice related data in Magento 2.

Get Invoice related data using below code snippet in Magento 2 by Invoice id,

Pass Invoice id to fetch invoice records from a database table.
echo $invoice = $this->getInvoiceData();



4 Replies to “Get Invoice data by invoice id Magento 2.”

      1. I had found that. We can get by below comment.

        public function getinvoiceordproduct($invoice_entity_id){
        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $invoice = $objectManager->create('MagentoSalesApiDataInvoiceInterface')->load($invoice_entity_id);

        //Loop through each item and fetch data
        foreach ($invoice->getAllItems() as $item)

        $ordproduct = mb_strimwidth($item['name'], 0, 15, "..." ). "x".floor($item['qty']);

        $ordproducts[] = $ordproduct;

        return $ordproducts;

Leave a Reply