How to change programmatically order status and add comment in history in magento?

programmatically change order status and add comment in history in magento

<?php

 $orderId = 100000821; // you're order Id
$order = Mage::getModel('sales/order')->load(orderId );
$order->addStatusToHistory($order->getStatus(), 'Put your comment here', false);
                     OR
$order->addStatusToHistory('complete', 'Put your comment here', false);
/* 1st parameter is status,
2nd is comments,
3rd is notified customer. */

$order->save();

Note:- if you want to display status on front end than change this

 $order->addStatusToHistory($order->getStatus(), 'Put your comment here', false)->setIsVisibleOnFront(1); // customer can see new status
?>


Do you want programmatically complete and ship order in magento?


2 comments:

  1. I am grateful for this blog to distribute knowledge about this significant topic. Here I found different segments and now I am going to use these new instructions with new enthusiasm.
    บริการ รับ ส่ง เอกสาร

    ReplyDelete
  2. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. History of perfume

    ReplyDelete