How to get last order status history comment and order status Magento 2
To retrieve latest order's comment history you can do following:
$histories = $order->getStatusHistories();
/** @var OrderStatusHistoryInterface $caseCreationComment */
$latestHistoryComment = array_pop($histories);
$comment = $latestHistoryComment->getComment();
$status = $latestHistoryComment->getStatus();
To add new history comment to the created order you can use Magento\Sales\Model\Order\Status\HistoryFactory
and \Magento\Sales\Api\OrderStatusHistoryRepositoryInterface
:
/** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
$history = $historyFactory->create();
$history->setParentId($order->getId())
->setComment($comment)
->setEntityName('order')
->setStatus($status);
$historyRepository->save($history);