How to get node comments programmatically in drupal 8 & 9
Example How to get node comments programmatically in drupal 8 & 9 :
$entity_manager = \Drupal::entityTypeManager();
$cids = $entity_manager
->getStorage('comment')
->getQuery('AND')
->condition('entity_id', 'NODE_ID')
->condition('entity_type', 'node')
->condition('comment_type', 'post_trp_comments')
->execute();
$comments = [];
foreach($cids as $cid) {
$comment = Comment::load($cid);
$comments[] = [
'cid' => $cid,
'uid' => $comment->getOwnerId(),
'subject' => $comment->get('subject')->value,
'body' => $comment->get('field_comment_body')->value,
'created' => $comment->get('created')->value
];
}