How to Get Shipment item collection by order item id Magento 2?

You can retrieve partial shipment items collection by Order item id using Magento 2 with search criteria Builder interface.

This is the rare condition where you need to fetch the list of shipment items from the Order item id.

This situation will be needed when order item id has multiple quantities placed and did partial shipmen for the separate quantity of each item.

Let’s take an example like You have placed an order with SKU “24-MB01” product with 5 quantity and you are doing a partial shipment for SKU with 5 times. (1 quantity at a time in each shipment)

Shipment items entry generated in the sales_shipment_item table.

When you check the shipment items in the sales_shipment_item table, You can see 5 different entries for each partial shipment.

API Interface used to fetch shipment items:
Magento\Sales\Api\ShipmentItemRepositoryInterface

Now you can get the collection of each shipment items using the below code snippet,

Call from a template or PHP class,
Here Don’t confuse  Order Item id with Order Id. Take Order_item_id only.

Iterate over a $shipmentItem to get the list of available shipment items for a specific order item id.