Pages

Monday, 23 June 2014

How to create Shipment Programmatically in magento

If you have not read previous articles yet, I strongly advise you to do so.  Here I will explain how to create Shipment Programmatically.
For automization magento we required auto create a shipment.

therefor I decide to write blog for create shipment by code so after placing an order it will auto generate shipment.

 Following are the steps for create a shipment .

 step 1: create shipment by code

try
        {
            $order = Mage::getModel('sales/order')->load('100000004');
            $itemQty =  $order->getItemsCollection()->count();
            $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
            $shipment = new Mage_Sales_Model_Order_Shipment_Api();
            $shipmentId = $shipment->create('100000004');
            $this->_redirect('test/index/index');
        }
        catch(Mage_Core_Exception $e)
        {
            print_r($e->getMessage());
        }
 
If run above code successfully created the shipment.
 
How to create Shipment Programmatically in magento
If you have any queries please leave a comment.

No comments:

Post a Comment