Magento 2 – Get Order Comments from Order ID

Posted on March 29, 2021 by jamie


If you have $order object then you can easily get the order comment history by,


If you don’t have $order object then you can use like this,

use Magento\Sales\Model\OrderFactory as OrderFactory;

protected $orderFactory;

public function __construct(
    OrderFactory $orderFactory  
) {
    $this->orderFactory = $orderFactory;    

$order = $this->orderFactory->create()->load('YOUR_ORDER_ID');

EDIT If you need order comment then please try this,

$orderComment = [];
foreach ($order->getStatusHistoryCollection() as $status) {
    if ($status->getComment()) {
        $orderComment[] = $status->getComment();

At the end, you have all order comments in $orderComment