I have csv having track number, order number, carrier name and tracking link now i want to insert tracking link for shipment in magento from csv

if (($handle = fopen("".$webshopimport_path."\\CSV\\trackandtrace.csv", "r")) !== FALSE)
    while (($data = fgetcsv($handle, 100000, ",")) !== FALSE)
        $comment = null;
        $email = false;
        $includeComment = false;
        $orderId = $data[5];                                                        //get ordernumber from csv
        $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
        $convertor = Mage::getModel('sales/convert_order');
        $shipment = $convertor->toShipment($order);

        foreach ($order->getAllItems() as $orderItem)
            if (!$orderItem->getQtyToShip()) {
            if ($orderItem->getIsVirtual()) {
            $item = $convertor->itemToShipmentItem($orderItem);
            $qty = $orderItem->getQtyToShip();

        $trackdata = array();
        $trackdata['carrier_code'] = $data[2];                                   //get carrier_code from csv
        $trackdata['title'] = $data[2];                                          //get title from csv
        $trackdata['number'] = $data[3];                                         //get track number from csv
        $trackdata['track_link'] = $data[4];                                         //get track link from csv

        $track = Mage::getModel('sales/order_shipment_track')->addData($trackdata);
        //echo "<pre>"; print_r($shipment);echo "<pre>"; exit;

        Mage::register('current_shipment', $shipment);

        $shipment->addComment($comment, $email && $includeComment);
        echo "<pre>"; print_r($shipment);echo "<pre>"; exit;

        $transactionSave = Mage::getModel('core/resource_transaction')

        $shipment->sendEmail($email, ($includeComment ? $comment : ''));

I am able to save track number, carrier name but not to save tracking link, please help me for this query

1 Answer 1


As far as I know adding the tracking_link is not a default feature of Magento. I took a look at the model and especially the database (as shown below) and there don't seem to be any fields for that.

enter image description here

Are you using some custom extension for tracking shipments?

  • I am new to use magento, i try out with adding field in above table and data goes inserted in that now i want to fetch track_number, track_link, carrier_code, created_at and want to show it on from side (tracktrace.phtml)
    – M Gaidhane
    Nov 20, 2013 at 17:20
  • if i need to create custom attribute then please suggest me way for the same.
    – M Gaidhane
    Nov 20, 2013 at 17:23
  • You should be able to call this value from the model Mage::getModel('sales/order_shipment_track')->load([ID])->getData('track_link'); if you've added the column in the database Nov 21, 2013 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.