Get Shipment collection details by order id Magento 2.

You can get the Shipment data or collection for the specific order by order id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface, you need to use getList() function to fetch no. of Shipment by sales order id.

Using SearchCriteriaBuilder Class, You need to use addFilter() method, filter by order id and pass searchCriteria object to getList() method of ShipmentRepositoryInterface. Continue reading “Get Shipment collection details by order id Magento 2.”

Count total shipment for an order by order id Magento 2.

You can count the no. of Shipment generated for the specific order by order id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface you need to use getList() method with SearchCriteriaBuilder Object to add filter by order id.

Using Below code snippet, You can fetch the count of shipment for an order, Continue reading “Count total shipment for an order by order id Magento 2.”

Delete Shipment by shipment id Magento 2.

You can delete the Specific Shipment data by shipment id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface, you need to use delete() method to delete shipment data from the shipment table.

You must first fetch the Shipment object by id and then pass the Shipment object as a parameter in delete() method to delete specific Shipment. Continue reading “Delete Shipment by shipment id Magento 2.”