programatically change order status magento 4 comments


require_once '../app/Mage.php';
umask(0);
Mage::app('default');

/*
    const STATE_NEW             = 'new';
    const STATE_PENDING_PAYMENT = 'pending_payment';
    const STATE_PROCESSING      = 'processing';
    const STATE_COMPLETE        = 'complete';
    const STATE_CLOSED          = 'closed';
    const STATE_CANCELED        = 'canceled';
    const STATE_HOLDED          = 'holded';
    const STATE_PAYMENT_REVIEW  = 'payment_review';
 */
$orderId = '200000120';
$order = Mage::getModel('sales/order')->loadByIncrementID($orderId);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
$order->save();

echo "<br />Status Updated";
?>

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools


4 thoughts on “programatically change order status magento

  • Sam

    Which php file do i put this code in?
    I am trying to programtically change status of orders which have particular shipping method
    for eg.
    $order = Mage::getModel(‘sales/order’)->getCollection()->addFieldToFilter(‘shipping_description’,’some_random_shipping_name’))->getFirstItem();

    then I want to set the status which I have created using the new feature in 1.5 and assign that status to these orders.
    Are there any ideas how can I do this?
    Thanks

    • Pragnesh Karia Post author

      Hello Sam,
      You have to make one php file , inside your ROOT folder, where magento installed.

      Then you have to put this code inside it.
      Make sure that
      require_once ‘../app/Mage.php’;
      can access your app/Mage.php.

      I have passed Order Number static here.

      You can make it as dynamic.
      You can also make php class and add this code as some function and you can pass order number as a parameter to that function.

      Thats it..

      Best Luck..!!