We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16313
    • 71 Posts
    Thanks Bruno for your assistance!
      • 40387
      • 28 Posts
      How do I join?
        • 4172
        • 5,888 Posts
        what do you want to join? Whats your db-schema for the tables to join?
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 40387
          • 28 Posts
          it is possible to join this items image that I send? because I did not understand your answer too because my English is not so good.
            • 40387
            • 28 Posts
            Hello man, what I want to do is something like 'migxcart', an item related to another, how can I do this? explain to me step by step?
              • 30319
              • 406 Posts
              Is it possible to do a "product catalog" site with different product categories??
              Which rtfm or tutorial should I read to understand how to do a 1-M database setup which has categories containing multiple products and the same product may be in multiple categories??
              Thank you, Tom
                • 40387
                • 28 Posts
                Quote from: nandopacheco at May 15, 2013, 07:03 AM
                Hello man, what I want to do is something like 'migxcart', an item related to another, how can I do this? explain to me step by step?
                  • 16313
                  • 71 Posts
                  Quote from: Bruno17 at Dec 17, 2012, 02:07 AM
                  you 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:
                  [{"alias":"yourAlias"}]


                  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.
                    • 16313
                    • 71 Posts
                    I've solved this issue. Point is that Join Alias does not work with JSON string. So I can put only one alias there.

                    Therefore I used Joins conditions. Here is my code:
                    [{"classname":"modResource","alias":"Product","on":"Product.id=product_id"},{"classname":"modResource","alias":"Category","on":"Category.id=category_id"}]
                      • 4172
                      • 5,888 Posts
                      did you try

                      [{"alias":"Product"},{"alias":"Category"}]
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!