如何在Magento SOAP API中找到应用于订单的装运


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

以下是销售订单的API文档:http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.info.html

以下是装运的API文档:http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/salesOrderShipment.html

我一辈子都想不出如何在他们之间建立关系。订单/信息端点似乎没有返回任何类型的shipment_id,订单/装运端点似乎不可按order_id进行筛选。

这可以通过对订单的order_id值使用过滤器来实现。

注意,order_id与订单的increment_id不同,后者是面向客户的常见参考号。因此,需要额外的步骤将订单的引用转换为order_id

我不能给你工作的PHP代码,我在Java中工作,但我可以描述方法:

  1. 使用sales_order.info API调用获取订单号(increment_id)的订单数据
  2. 从订单数据中获取order_id
  3. 使用order_id作为sales_order_shipment.list中的筛选器
  4. 这将为您提供一份货运清单,每个货运清单上都有一个increment_id。此id是发货的参考号
  5. 使用sales_order_shipment.info中装运的increment_id获取更多详细信息

以下是完成@Kevin Sadler答案的PHP代码:

/** @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);