给定一个 magento 订单对象,我如何找到与该订单关联的跟踪号?
$order = Mage::getModel('sales/order')->loadByIncrementId(100000064);
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
->setOrderFilter($order)
->load();
foreach ($shipmentCollection as $shipment){
// This will give me the shipment IncrementId, but not the actual tracking information.
$shipment->getData();
}
最佳答案
我也在这个问题上挣扎,返回空值。不过终于想通了。首先,如前所述,检索与给定订单关联的货件集合:
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
->setOrderFilter($order)
->load();
foreach ($shipmentCollection as $shipment){
// This will give me the shipment IncrementId, but not the actual tracking information.
foreach($shipment->getAllTracks() as $tracknum)
{
$tracknums[]=$tracknum->getNumber();
}
}
数组 $tracknums 现在将包含链接到此订单/发货的每个跟踪号。
关于来自订单对象的 Magento 跟踪号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5737276/