B-219 Sec-55 Noida, India
+918010221733

How to create Shipment programmatically in magento

Below is a php code to create a shipment for an order in magento.

$order = Mage::getModel(‘sales/order’)->loadByIncrementId(‘100000001’);

try {
    if($order->canShip()) {
        //Create shipment
        $shipmentid = Mage::getModel(‘sales/order_shipment_api’)
                        ->create($order->getIncrementId(), array());
        //Add tracking information
        $ship = Mage::getModel(‘sales/order_shipment_api’)
                        ->addTrack($order->getIncrementId(), array());      
    }
}catch (Mage_Core_Exception $e) {
 print_r($e);
}

(Visited 120 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.