$statusBefore =
$order->
getOrderStatus();
$clearedBefore =
$order->
getPaymentStatus();
// Refresh the status models to return the new status data which will be displayed in the batch list
if (!
empty($data['status'
]) ||
$data['status'
] === 0
) { $order->
setOrderStatus($modelManager->
find(Status::
class,
$data['status'
]));
} if (!
empty($data['cleared'
])) { $order->
setPaymentStatus($modelManager->
find(Status::
class,
$data['cleared'
]));
} try { $modelManager->
flush($order);
} catch (Exception
$e) { $data['success'
] = false;
$data['errorMessage'
] =
sprintf( $namespace->
get('save_order_failed', 'Error when saving the order. Error: %s'
),
$e->
getMessage() );
continue;
}