Quote from: Bruno17 at Dec 17, 2012, 02:07 AMyou can use the joins-configuration
if you have an aggregate or composite - alias for the joined table in your xpdo-schema you can use:
joins:
if you don't have a relation defined in your schema you can use:
joins:
[{"classname":"YourClassname","alias":"yourAlias","on":"yourAlias.id=yourRelationIDfield"}]
then you can use for example: yourAlias_title as fieldnames in your grid
Hello Bruno
I need your assistance for solving this issue.
Table modx_product_categories jointed with table modx_site_content by to fields: product_id and category_id.
I've created following xml schema:
<object class="Category" table="site_content" extends="xPDOObject">
<field key="id" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<composite alias="cProductSort" class="productSort" local="id" foreign="category_id" cardinality="many" owner="local" />
</object>
<object class="Product" table="site_content" extends="xPDOObject">
<field key="id" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<composite alias="pProductSort" class="productSort" local="id" foreign="product_id" cardinality="many" owner="local" />
</object>
<object class="productSort" table="product_categories" extends="xPDOSimpleObject">
<field key="product_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<field key="category_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<field key="catindex" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<aggregate alias="Product" class="Product" local="product_id" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Category" class="Category" local="category_id" foreign="id" cardinality="one" owner="foreign" />
</object>
Then I added Join Alias [{"alias":"Product","alias":"Category"}] to config and I receive following error:
No foreign key definition for parentClass: productSort using relation alias: [{"alias":"Product","alias":"Category"}]
Could you tell me what I'm doing wrong.
Thanks.