B-219 Sec-55 Noida, India
+918010221733

Save shipment information of order programatically

Magento: Save shipment information of order programatically

After creating invoice and shipment, it is necessary to add tracking information to shipment. Here is how to write a observer which will invoke as shipment save method is called and save tracking information programatically.

config.xml – under global -> events node
                       
                        singleton
                        Namespace_Modulename_Model_Observer
                        salesOrderShipmentSaveBefore
                  
              
          
Observer.php -> under Model directory of module

public function salesOrderShipmentSaveBefore($observer)
    {
            $shipment = $observer->getEvent()->getShipment();
            $track = Mage::getModel(‘sales/order_shipment_track’)
                        ->setNumber(‘824343454454’) //tracking number / awb number
                        ->setCarrierCode(‘aramex’) //carrier code
                        ->setTitle(‘Aramex’); //carrier title
                    $shipment->addTrack($track);
       }

(Visited 52 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.