Query Paragraph Type in Drupal 8

3.5k Views Asked by At

I am trying to Query all paragraphs of a certain type but I am not getting any output. Is my query right? Currently being returned an empty array.

$query = $this->node->getQuery()
          ->condition('type', 'my_paragraph_type')
          ->execute();
        $this->logger->info('query: ' . json_encode($query));
1

There are 1 best solutions below

0
zanvidmar On

Try with entityQuery('entity_type')

$pids = \Drupal::entityQuery('paragraph')
  ->condition('type', 'my_paragraph_type')
  ->execute();