cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add tracking number to current order shipment in Magento 2?

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

How do I add tracking number to current order shipment in Magento 2?

I did find sample codes for Magento 1.x. But I have no idea how to do this on Mag2.

 

Can anyone describe how to implement this using dependency injection (DI)?

 

Thanks.

 

 

$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()
 

 

 

 

1 REPLY 1

Re: How do I add tracking number to current order shipment in Magento 2?

Found a solution here. Sharing it for readers benefit.

 

Thanks.