Can xPDO gather objects linked by foreign keys?

That’s a simplified version I posted here. The whole file is 566 lines.

I can’t include the whole file because: Body is limited to 32000 characters; you entered 33032. Haha.

Sorry for the confusion, I just thought it’s easier to look at the parts of the file that were in question for simplicity.

Edit: Currently I am able to get all my custom objects with getObject, or getCollection, but it would seem that no matter what I do I am unable to notify the MODX that I have added the aggregate and composite elements within the XML file.

Maybe we should approach again tomorrow as I find that new ideas spring up after a problem is left alone for some time.

Thank you for the help @bruno17, if you have a brainstorm please let me know.

Edit 2: Here’s a link to the entire schema file on github.
The Product related objects start at line 601.

You can see why I didn’t include entire file in forum posts.

I performed the parseSchema on that file, cleared cache a few times, still getting same error. Last posted snippet is current executing snippet.

Hopefully tomorrow will bring new ideas for me. Now, I use refrigerator door as head bashing target and crawl to bed a sad human. :smile:

It looks like your Association alias is not unique.


You do know you have to regenerate the class and map files whenever you modify the schema, right? At runtime, MODX pays no attention to the schema file.

I think, that doesn’t matter, if you have the same composite/aggregate alias on different objects, does it?

I see, you have double defined indices, like here

this would duplicate them, when you create tables from that schema

and I see lot of fields with null=“false” but no default value

and it seems, there are cardinalities defined as many, which should be defined as one

for example this index

has unique=“true” but you have the cardinality defined as many

Hmm perhaps not… I’ve never tried without them being unique to be honest.

I’m regenerating the class & map files.

First I generate the map, schema, class files from the database with the script in the documentation. @bruno17, so any of the double defined indices are generated by the MODX engine.

Then I edit the schema to have those aggregate and composite relations.

Then I run the script to update the class & schema files as shown in the documentation.

I observe no changes to the class and map files. They look exactly the same after adding the aggregate and composite relations and uncommenting those lines of code that are calling parseSchema.

Is there another method I need to call to update the class/map files or is that what parseSchema is supposed to do?

That’s a really good question that I don’t know the answer to.

I had always understood that the schema files were ignored at runtime, but your experience suggests that I might be wrong about that, unless you’re looking at the wrong files.

@NuzyWeb Are you still working on this? Just thought I’d check. If you’ve already made progress or gone a different route no need for me to reply :slight_smile:

If you are still working on it, I’ll provide some thoughts… not sure if they’ll be helpful but I’ll provide them.

A few questions if you are still working on it.

  1. Are you porting something working to Modx or building something entirely new?
  2. You are definitely trying to build it on top of Modx and have it embedded and using xPDO? It seems like this is a yes, but wanted to be sure. Have the ability to install it as an Extra?
  3. Can you show a screenshot of a generated table name in your modx database? Are they being generated as “modx_pre_address” or just “pre_address”?