Magento2 Invoice – How to Get Invoice Item List Using SQL Query

invoicemagento2

I am using magento 2 and how can I get list of items on specific invoice?
I tried sql query with sales_invoice and sales_invoice_item table, but I couldn't get it. There are 2 same rows because of the sub-item(matrix item)
Please give some tips. Thanks!

Best Answer

For resolved this sub items issue, you need to take those entity_id whose order_item_id's sales_item table's parent_item_id is null.

This two tables have a relation via sales_invoice_item.order_item_id=sales_order_item.item_id

So, can run below query

SELECT * FROM `sales_invoice_item` as invoice_item, sales_order_item as order_item 
where invoice_item.order_item_id = order_item.item_id and order_item.parent_item_id is null
and invoice_item.parent_id = [INVOICE_ID]
Related Topic