if ($documentType !== 0
) { $this->
createOrderDocuments($documentType,
$documentMode,
$order);
} if ($previousLocale) { // This is necessary, since the "checkOrderStatus" method might change the locale due to translation issues
// 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;