I want to send SMS to customers when ever an order status changes from pending > processing > complete (for all sort of changes).

For pending process(when place order is clicked), i should able to get a SMS. Below is the code: Onserver.php

public function sendSMS ($observer)
        $orderIds = $observer->getEvent()->getOrderIds();
        foreach($orderIds as $orderId)
            $order = Mage::getModel('sales/order')->load($orderId);
            $orderId = $order->getId();
            $order_status = $order->getStatus();
            $smsMessageTemp =Mage::getModel('core/variable')->loadByCode('template_sms_order_placement_confirmation')->getValue('plain');
                . . . . .

When admin changes the state from pending to processing , how to send sms for different events.

In my .xml file:


Please suggest.


2 Answers 2


First you need to track order status changes,

Magento is provide to track old data and new changed data using getOrigData() and getData() on save event fire.So easily using the feature,you can get changes Status and on basic of this,you can fire the Sms


When sales_order_save_after event is fire then you can get only one order data that means code at observer is wrong.


As i said that when Model is saving then you can get old and new Data using

Current Data: $Object->getOrigData();


Changing new Data : $object->getData()

Using those function when you can easy track order status changes.

And suggesting to you that use event sales_order_save_commit_after instead of sales_order_save_after because if any issue has occurred during the save magento is roll back to old data and show the errors.

you can Old status by $OldStatus=$order->getOrigData('status')

and new Status



  public  function sendSMS($observer)
        $order = $observer->getEvent()->getOrder();

        if (!$order->getId()) {
            //order not saved in the database
            return $this;

        /* @var $order Mage_Sales_Model_Order */


        /* Fire sms when New Status  and  old Statu are not same */
            //fire sms;
            $smsMessageTemp =Mage::getModel('core/variable')->loadByCode('template_sms_order_placement_confirmation')->getValue('plain');

        return $this;
  • 1
    why down vote??
    – Amit Bera
    Commented May 15, 2015 at 12:28
  • sr_magento ,i am agree with you
    – Amit Bera
    Commented May 15, 2015 at 14:44
  • maybe because you are reinventing bicycle again and again??? magentocommerce.com/magento-connect/catalogsearch/result/… take one of these extensions and use it, or see how its built and do your own...
    – user2857
    Commented May 17, 2015 at 8:37
  • @SR_Magento, Amit. I am agree with you both. because some people dont like answers, then they are downvoting. but if they give the explanation, that should helps to someone. Commented Feb 21, 2017 at 4:52

Tracking order status code and applying sms api on each event is little difficult.

Its easy to use "extension" available free for magento like "Spring Edge Magento sms extension" which is Compatible with: Magento versions 1.x and 2.x

Magento sms module events configuration :

  • Send sms to customer and admin on new order is placed.
  • When order status is set to hold.
  • When order status is set to Unhold.
  • When order is cancelled.
  • When order status is set Shipment.


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.