Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set order status as 'complete' in magento

Tags:

magento

how do i set order status as 'complete' manually.

I am using the following code, but its giving error saying, The Order State 'complete' must not be set manually.

$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
        $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE);
        $order->save(); 
like image 643
user2629419 Avatar asked Sep 10 '13 05:09

user2629419


1 Answers

i found a solution for my self,

$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
        $order->setData('state', "complete");
        $order->setStatus("complete");       
        $history = $order->addStatusHistoryComment('Order was set to Complete by our automation tool.', false);
        $history->setIsCustomerNotified(false);
        $order->save();
like image 85
user2629419 Avatar answered Sep 19 '22 12:09

user2629419