On the first document that has children, it fails, telling me that $resource->Children is not an object.
Duh again. $resource->Children isn’t an object (unlike $user->Profile). It’s an array of objects.
Yes. getMany vs. getOne
In your case you use the xGraph methods, so you’ll have to know what you expect.
although it’s the same, sometimes it’s better to use the getMany/getOne and not the xGraph methods - then you know for sure what to expect. You can also take a look at \core\model\schema\modx.mysql.schema.xml to see how the relationships are defined.
btw, take a look at this tip:
http://modxcms.com/forums/index.php?topic=44049.0
If I do print_r($resource->Children), (rather than Children->toArray()) I get a monstrous dump of everything from soup to nuts, but no errors.
Sure.. depanding on your php settings you can even just get an endlessly long loading page...
just use the ->toArray() or a ->get() specific field - anyway it’s temporary, you do this print_r only for tracing/debugging.