// when sending an order status mail. Therefore, we reset it here to the chosen backend language.
$this->
get('snippets'
)->
setLocale($previousLocale);
$this->
get('snippets'
)->
resetShop();
} $data['paymentStatus'
] =
$stateTranslator->
translateState(StateTranslatorService::STATE_PAYMENT,
$modelManager->
toArray($order->
getPaymentStatus()));
$data['orderStatus'
] =
$stateTranslator->
translateState(StateTranslatorService::STATE_ORDER,
$modelManager->
toArray($order->
getOrderStatus()));
try { // The method '$this->checkOrderStatus()' (even its name would not imply that) sends mails and can fail
// with an exception. Catch this exception, so the batch process does not abort.
$data['mail'
] =
$this->
checkOrderStatus($order,
$statusBefore,
$clearedBefore,
$autoSend,
$documentType,
$addAttachments);
} catch (Exception
$e) { $data['mail'
] = null;
$data['success'
] = false;
$data['errorMessage'
] =
sprintf( $namespace->
get('send_mail_failed', 'Error when sending mail. Error: %s'
),
$e->
getMessage() );
continue;
} $data['success'
] = true;