You can check the shipment comments by Magento 2 using Shipment Comment Repository Interface with shipment id.
Shipment comment repository interface used to fetch comment data of a shipment. Useful Interface is, Magento\Sales\Api\ShipmentCommentRepositoryInterface
Check the code to fetch comment by comment id,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php namespace Jesadiya\ShipmentComment\Model; use Magento\Sales\Api\ShipmentCommentRepositoryInterface; class ShipmentCommentByCommentId { /** * @var ShipmentCommentRepositoryInterface */ public $shipmentCommentRepository; public function __construct( ShipmentCommentRepositoryInterface $shipmentCommentRepository ) { $this->shipmentCommentRepository = $shipmentCommentRepository; } /** * Get Shipment comment data * * @return string */ public function getShipmentComment($commentId) { $comment = $this->shipmentCommentRepository->get($commentId); return $comment; } } |
call method from a template or PHP class,
1 2 | $commentId = 1; $this->getShipmentComment($commentId); |
Pass Comment id, you need to get a comment for the shipment.
You got the response as shipment comment data.