2
如何在Magento 2的当前订单发货中添加跟踪号?
我确实找到了Magento 1.x的示例代码。但是我不知道如何在Magento 2上执行此操作。 谁能描述如何使用依赖注入(DI)来实现这一点? 谢谢。 $trackingDetail = array( 'carrier_code' => 'ups', 'title' => 'United Parcel Service', 'number' => 'TORD23254WERZXd3', // Replace with your tracking number ); $track = Mage::getModel('sales/order_shipment_track')->addData($trackingDetail); $shipment->addTrack($track); $transactionSave = Mage::getModel('core/resource_transaction') ->addObject($shipment) ->addObject($shipment->getOrder()) ->save();