I want to auto create the shipment id for the magento order as soon as the order arrives, the shipment id gets created only when we invoice, so can you please tell me how to do it as soon as order arrives?

  • can anyone answer this please – adee Feb 14 '18 at 6:17

You need to create a custom extension with the observer of the following events:


Where you can get order increment ID and use Magento API for the creation of shipment:

Mage::getModel('sales/order_shipment_api_v2')->create($orderIncrementId, array(), '', false, false);

You can check params of the create function here, probably it will be useful to use some of these, like sending email or adding of comment:


Also, I advise to surround this code by a try block, to facilitate the catching of potential exceptions. You can stumble upon the pitfalls during getting of an increment id of order if you are using multishipping feature in your Magento. So you need use code, something like this:

$orders = $observer->getOrders(); // multishipping
if (!$orders) {
    $orders = array($observer->getOrder());
foreach ($orders as $order) {
    $orderIncrementId = $order->getIncrementId();
    try {
        Mage::getModel('sales/order_shipment_api_v2')->create($orderIncrementId, array(), '', false, false);
    } catch (Exception $e) {
        Mage::log($e->getCustomMessage(), null, 'Auto_Shipment.log', true);

Please pay attention, I am using the getCustomMessage method, because $e is an instance of the Mage_Api_Exception class and using of the getMessage method will cause the Fatal error.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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