Want to add tracking information to an existing Magento shipment? Here is the code you can use: $shipment = $order->getShipmentsCollection()->getFirstItem(); $trackingNumber = ’12345678′; $track = Mage::getModel(‘sales/order_shipment_track’) ->setShipment($shipment) ->setData(‘title’, ‘title’) ->setData(‘number’, $trackingNumber) ->setData(‘carrier_code’, ‘carrier code’) ->setData(‘order_id’, $shipment->getData(‘order_id’)) ->save();
Getting an orders tracking information (Magento 1)
Using the following code, you can obtain the tracking information of a Magento order.
|
1 2 3 4 |
$trackingCollection = $order->getTracksCollection(); $firstItem = $trackingCollection->getFirstItem(); $trackingNumber = $firstItem->getNumber(); ... |