I am trying to setup a Cron to automatically update order statuses that have a are in a "Processing" state in Magento.

Here is what I have so far


        <schedule><cron_expr>0 9,11,13,15,17 * * *</cron_expr></schedule>
        <!--schedule><cron_expr>*/15 * * * *</cron_expr></schedule-->


And inside Status.php

public function updateOrderStatus($order)




What I would like to do is change any orders from "Processing" to "Packing" but I can't seem to find a way to do it...

If anyone knows any good resources please share.

  • You might need to post your whole code, as I am not 100% sure where everything is at, or if you are calling the correct functions.
    – kab8609
    May 28, 2014 at 14:15

2 Answers 2


There are a few things that seem to need correcting:

  • The xml is calling the wrong function


This line says to look in the orders module (though that it is a bit of an oversimplification) and look for a Model called Status and run the cron() function

What you probably want to do is change the line to this:


  • The updateOrderStatus() function does not have access to your orders

Even though the function has a parameter called $order it does not act like an observer where the object is there automatically.

In other words: the order collection needs to be loaded with the following code:


The collection should be narrowed to what you need (see below).

The function should end up looking like this:

public function updateOrderStatus()
    // lets get all the orders that their status is 'pending'
    $orders = Mage::getResourceModel('sales/order_collection')
         ->addFieldToFilter('status', 'pending');
     // loop through each order, set the new status and try to save, if it fails, log why (this way we'll know)
     foreach($orders as $order){
                }catch(Exception $e){
                  Mage::log('Couldn\'t save order' . $order->getId());
  • Thankyou, that really has helped me alot... May 29, 2014 at 18:19
  1. that means magento is trying to call the cron-method in your status-model. if you have set the alias for your models correct ( in your example to "orders" ) then magento tries to find this method in /yourmodule/Model/Status.php. The function in this file should have the name "cron"

  2. there will be no $order-variable to work with

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.