I am loading multiple node ids like below

$node_storage = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($nids);
foreach ($node_storage as $node){
  $value = $node->get('field_merchant_id')->value;

After this, I am getting an object and I don't know how to access my values. I have used get('field_name')->value but its saying Error: Call to a member function get() on array. How can I get an array that contains all values of one specific column from all nodes?

1 Answer 1


You should do like

$node_storage = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
foreach ($node_storage as $node){
   $field_merchant_id = $node->get('field_merchant_id')->value;

Here you are using "user" which should be replaced by "node" to access node values. And also to access "field_merchant_id", you need to get that from $node.

  • This is actually what I had done and got that error, sorry about that mistake, i have edited my question Commented Oct 26, 2017 at 12:07
  • Try like above code. It should work and just pass $nids as node id's
    – Ajay Reddy
    Commented Oct 26, 2017 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.