Magento – Add status history problem

historystatus

I'm trying to change an order status in controller. After execute "addStatusToHistory" and "->save()", it save the comment and status that I've specified. But after that it apply a new status to order, just in case, the first status in status list for comments. Does anyone know something about it?

$_order = Mage::getModel('sales/order')->load($idOrder);
$history = $_order->addStatusToHistory('etiqueta_impressa','Etiqueta impressa via Ferramentas > SIGEP em: '.date("d/m/Y H:i:s"),false);
$history->setIsCustomerNotified(false);
$_order->save();

Best Answer

Have a state related to status etiqueta_impressa?

Try set status and add history comment separately, and search for observers after save order.

$_order = Mage::getModel('sales/order')->load($idOrder);

$_order->setStatus('etiqueta_impressa');

$comment = 'Etiqueta impressa via Ferramentas > SIGEP em: '.date("d/m/Y H:i:s");
$history = $_order->addStatusHistoryComment($comment, false);
$history->setIsCustomerNotified($isCustomerNotified);

$_order->save();
Related Topic