Accessing entries in a matrix field in plugin I am writing a plugin function that takes an entry id, the entry has a matrix field (called block) and the matrix has a blocktype which contains a number field (blockStep), an entries field (blockContent) and another entries field (blockDependency).

I am getting the entry, which i am calling a module, like this:

$module = craft()-&gt;entries-&gt;getEntryById($moduleid);


This works fine. Then I get the matrix field, called block, like this:

$matrixBlocks = $module-&gt;block;


This also works fine. However, when I try to loop through the matrix field, like this:

    foreach ($matrixBlocks as $block){
      var_dump( $block-&gt;getContent()-&gt;blockStep);
      var_dump( $block-&gt;getContent()-&gt;blockContent);
      var_dump( $block-&gt;getContent()-&gt;blockDependency);
    }


Only the blockStep, which is a number, is set - the two entries fields are just returning NULL.

Can someone help? How should I be accessing these entries fields?

Thank you.
I think I've figured out how to do this now (mainly through trial and error).
The code above should actually be like this:

foreach ($matrixBlocks as $block) {

    foreach ($block-&gt;blockContent as $blockContent) {
        ....
    }
    foreach ($block-&gt;blockDependency as $blockDependency){
        ....
    }
}


And the the $blockContent and $blockDependency variables will contain the entries required.