How do you find the shipments applied to an order

2019-08-09 01:25发布

问题:

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.

回答1:

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.


回答2:

Here is the PHP code to complete @Kevin Sadler answer:

/** @var array $filters */
$filters = array(
    array('order_id' => array('eq' => $orderId)) // Entity ID, not Increment ID
);

/** @var array $orderShipments */
$orderShipments = $client->call($session, 'sales_order_shipment.list', $filters);


标签: php magento soap