How to get field value after getting a node? I have a content type which contains school information. School name and school id are two fields in the content type. I have the school ID and I am able to retrieve the node. How do I get the school name? Below is how I retrieve the particular school node. I used the getValue() to retrieve the school name however, I get an empty array as a response for that. I am able to see the school name if I var_dump the school node.

$schoolNode = \Drupal::entityTypeManager()
      -&gt;getStorage('node')
      -&gt;loadByProperties(['field_school_id' =&gt; $item['schoolId']]);
$schoolNode-&gt;field_school_name-&gt;getValue()
If you want to use node object from entityTypeManager, you need to get current value from the array after loading like below:

$schoolNode = \Drupal::entityTypeManager()
      -&gt;getStorage('node')
      -&gt;loadByProperties(['field_school_id' =&gt; $item['schoolId']]);
$node_load = current($schoolNode);
$schoolname = $node_load-&gt;field_school_name-&gt;getValue();


This is only for a single node. If you have multiple nodes, foreach node as

foreach(schoolNode as $node){
  $schoolname = $node-&gt;field_school_name-&gt;getValue();
}