Search code examples
phpmagentomagento-soap-api

How do you find the shipments applied to an order in the Magento SOAP API?


Here is the API Documentation for a Sales Order: http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.info.html

Here is the API documentation for a Shipment: http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/salesOrderShipment.html

I cannot for the life of me figure out how to establish a relationship between them. The order/info endpoint doesn't seem to return a shipment_id of any kind and the order/shipment endpoint doesn't seem to be filterable by order_id.


Solution

  • This is possible by using a filter on the order's order_id value.

    Note that order_id is different to the order's increment_id which is the usual customer facing reference number. Therefore an extra step is required to convert the order's reference into the order_id.

    I can't give you working PHP code, I'm working in Java, but I can describe the method:

    1. Get the order data for your order number (increment_id) using sales_order.info API call
    2. get the order_id from the order data
    3. Use the order_id as a filter in sales_order_shipment.list
    4. This will give you a list of shipments each with an increment_id. This id is the shipment's reference.
    5. Use the shipment's increment_id in sales_order_shipment.info to get more details.