We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8274 ☆ A M B ☆
    • 222 Posts
    Overview: Modx 2.5, MIGX 2.9.6
    I have a MIGXdb config set up to list all the products in the catalog (productcatalog). I want to pull this into a different MIGXdb configuration (ProdClasses) that lists the categories. In a second tab of the category form, I want to pull in the productcatalog config BUT only show the items whose category id matches the one that is being edited.

    Schemas:
    productcatalog:
    {
      "formtabs":[
        {
          "MIGX_id":2,
          "caption":"General",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":6,
              "field":"prodno",
              "caption":"Product Number",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"text",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":1
            },
            {
              "MIGX_id":7,
              "field":"prodname",
              "caption":"Product Name",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"text",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":2
            },
            {
              "MIGX_id":12,
              "field":"hidden",
              "caption":" ",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"checkbox",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":" Hide Product?==1",
              "default":"0",
              "useDefaultIfEmpty":"0",
              "pos":3
            },
            {
              "MIGX_id":8,
              "field":"classid",
              "caption":"Category",
              "description":"",
              "description_is_code":"0",
              "inputTV":"ProductCategories",
              "inputTVtype":"",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":4
            },
            {
              "MIGX_id":9,
              "field":"description",
              "caption":"Description",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"richtext",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":5
            }
          ],
          "pos":1
        },
        {
          "MIGX_id":7,
          "caption":"Features & Inclusions",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":17,
              "field":"features",
              "caption":"Features",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"richtext",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            },
            {
              "MIGX_id":18,
              "field":"inclusions",
              "caption":"Inclusions",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"richtext",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":2
            }
          ],
          "pos":2
        },
        {
          "MIGX_id":3,
          "caption":"Specifications",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":13,
              "field":"specifications",
              "caption":"Specifications",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migx",
              "validation":"",
              "configs":"productspecs",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            }
          ],
          "pos":3
        },
        {
          "MIGX_id":4,
          "caption":"Model Options",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":14,
              "field":"options",
              "caption":"Model Options",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migx",
              "configs":"ModelOptions",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":1
            }
          ],
          "pos":4
        },
        {
          "MIGX_id":5,
          "caption":"Images",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":15,
              "field":"images",
              "caption":"",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migx",
              "validation":"",
              "configs":"images",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            }
          ],
          "pos":5
        },
        {
          "MIGX_id":6,
          "caption":"Accessories",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":16,
              "field":"accessories",
              "caption":"Recommended Accessories",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"richtext",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            }
          ],
          "pos":6
        }
      ],
      "contextmenus":"update||duplicate||activate||deactivate||recall_remove_delete||remove",
      "actionbuttons":"addItem",
      "columnbuttons":"",
      "filters":[
        {
          "MIGX_id":1,
          "name":"search",
          "label":"Search",
          "emptytext":"",
          "type":"textbox",
          "getlistwhere":{
            "prodno:LIKE":"%[[+search]]%",
            "OR:prodname:LIKE":"%[[+search]]%"
          },
          "getcomboprocessor":"",
          "combotextfield":"",
          "comboidfield":"",
          "comboparent":"",
          "default":""
        }
      ],
      "extended":{
        "migx_add":"",
        "disable_add_item":"",
        "add_items_directly":"",
        "formcaption":"Manage the catalog products in the grid below",
        "update_win_title":"Product Catalog",
        "win_id":"productcatalog",
        "maxRecords":"",
        "addNewItemAt":"top",
        "multiple_formtabs":"",
        "multiple_formtabs_label":"",
        "multiple_formtabs_field":"",
        "multiple_formtabs_optionstext":"",
        "multiple_formtabs_optionsvalue":"",
        "actionbuttonsperrow":3,
        "winbuttonslist":"",
        "extrahandlers":"this.handlePositionSelector",
        "filtersperrow":2,
        "packageName":"productcatalog",
        "classname":"Catalog",
        "task":"",
        "getlistsort":"",
        "getlistsortdir":"",
        "sortconfig":"",
        "gridpagesize":50,
        "use_custom_prefix":"0",
        "prefix":"",
        "grid":"",
        "gridload_mode":2,
        "check_resid":1,
        "check_resid_TV":"",
        "join_alias":"Images",
        "has_jointable":"yes",
        "getlistwhere":"",
        "joins":[
          {
            "classname":"ProdClass",
            "alias":"ProductCategory",
            "on":"ProductCategory.id=classid"
          }
        ],
        "hooksnippets":"",
        "cmpmaincaption":"Product Catalog",
        "cmptabcaption":"Products",
        "cmptabdescription":"  ",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":1,
          "header":"ID",
          "dataIndex":"id",
          "width":"",
          "sortable":"false",
          "show_in_grid":"0",
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":2,
          "header":"Product No",
          "dataIndex":"prodno",
          "width":50,
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"selectFromGrid",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":3,
          "header":"Name",
          "dataIndex":"prodname",
          "width":500,
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":4,
          "header":"Classification",
          "dataIndex":"ProductCategory_classname",
          "width":"",
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":5,
          "header":"Sort Order",
          "dataIndex":"menuindex",
          "width":"",
          "sortable":true,
          "show_in_grid":1,
          "customrenderer":"",
          "renderer":"this.renderPositionSelector",
          "clickaction":"selectFromGrid",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"",
          "editor":""
        }
      ]
    }


    Category (ProdClasses):
    {
      "formtabs":[
        {
          "MIGX_id":1,
          "caption":"Product Class",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":1,
              "field":"classname",
              "caption":"Classification Title",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":1
            },
            {
              "MIGX_id":5,
              "field":"shortname",
              "caption":"Display Name",
              "description":"An alternate name to display. Overrides the Category Name",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"text",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":2
            },
            {
              "MIGX_id":2,
              "field":"summary",
              "caption":"Category Summary",
              "description":"This is the text that will show up on the Section Landing page",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"richtext",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":3
            },
            {
              "MIGX_id":3,
              "field":"classimg",
              "caption":"Category Image",
              "description":"Choose an image to represent this category. If none is chosen, it will default to the first product of this category.",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"image",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":4
            },
            {
              "MIGX_id":4,
              "field":"classpri",
              "caption":"Priority",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"number",
              "configs":"",
              "sourceFrom":"config",
              "sources":"[]",
              "inputOptionValues":"",
              "default":"",
              "pos":5
            }
          ],
          "pos":1
        },
        {
          "MIGX_id":14,
          "caption":"Products",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":34,
              "field":"Products",
              "caption":"",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migxdb",
              "validation":"",
              "configs":"productcatalog",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            }
          ],
          "pos":2
        }
      ],
      "contextmenus":"update||duplicate||remove",
      "actionbuttons":"addItem",
      "columnbuttons":"update||duplicate||remove",
      "filters":"",
      "extended":{
        "migx_add":"Add Class Name",
        "disable_add_item":"",
        "add_items_directly":"",
        "formcaption":"",
        "update_win_title":"",
        "win_id":"ProdClasses",
        "maxRecords":30,
        "addNewItemAt":"bottom",
        "multiple_formtabs":"",
        "multiple_formtabs_label":"",
        "multiple_formtabs_field":"",
        "multiple_formtabs_optionstext":"",
        "multiple_formtabs_optionsvalue":"",
        "actionbuttonsperrow":2,
        "winbuttonslist":"",
        "extrahandlers":"this.handlePositionSelector",
        "filtersperrow":1,
        "packageName":"productcatalog",
        "classname":"ProdClass",
        "task":"",
        "getlistsort":"classpri",
        "getlistsortdir":"ASC",
        "sortconfig":"",
        "gridpagesize":"",
        "use_custom_prefix":"0",
        "prefix":"",
        "grid":"",
        "gridload_mode":2,
        "check_resid":"0",
        "check_resid_TV":"",
        "join_alias":"",
        "has_jointable":"no",
        "getlistwhere":"",
        "joins":"",
        "hooksnippets":"",
        "cmpmaincaption":"Category Manager",
        "cmptabcaption":" Categories",
        "cmptabdescription":" Manage the available product categories.",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":1,
          "header":"id",
          "dataIndex":"id",
          "width":"",
          "sortable":"false",
          "show_in_grid":"0",
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":3,
          "header":"Priority",
          "dataIndex":"classpri",
          "width":"",
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        },
        {
          "MIGX_id":2,
          "header":"Classification Title",
          "dataIndex":"classname",
          "width":"",
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"selectFromGrid",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"[]"
        }
      ]
    }


    how do i set up a conditional to remove the none matching items from productcatalog migxdb based on the current ProdClasses id (which is saved in the class_id field of the productcatalog db table)?

    Once pulled in, will I be able to edit the products listed from the ProdClass CMP?
      • 4172
      • 5,888 Posts
      To get the complete picture, can you give me your xpdo-schema, please?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8274 ☆ A M B ☆
        • 222 Posts
        for productcatalog:
        <?xml version="1.0" encoding="UTF-8"?>
        <model package="productcatalog" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                <object class="Catalog" table="prod_catalog" extends="xPDOSimpleObject" >
        <field key="menuindex" dbtype="tinyint" precision="4" attributes="unsigned" phptype="integer" default="0"/>
        <field key="prodno" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
                <field key="description" dbtype="text" phptype="string" />
        <field key="features" dbtype="mediumtext" phptype="string" />
        <field key="inclusions" dbtype="mediumtext" phptype="string" />
        <field key="accessories" dbtype="mediumtext" phptype="string" />
        <field key="classid" dbtype="text" phptype="string"/>
        <field key="accyid" dbtype="text" phptype="string"/>
                <field key="prodname" dbtype="text" phptype="string" null="false" default="" />
                <field key="specifications" dbtype="text" phptype="json" null="false" default="" />
        <field key="options" dbtype="text" phptype="json" null="false" default="" />
        <field key="images" dbtype="text" phptype="json" null="false" default="" />
        <field key="hidden" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" default="0"/>
         <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                <field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="id" collation="A" null="false" />
                </index>
                <aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="ProductCategory" class="ProdClass" local="classid" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="AccyCategory" class="AccyClass" local="accyid" foreign="id" cardinality="one" owner="foreign" />
        <composite alias="Images" class="ProdImg" local="id" foreign="prodid" cardinality="many" owner="local"/>
                </object>
            <object class="ProdImg" table="prod_images" extends="xPDOSimpleObject" >
                <field key="description" dbtype="text" phptype="string" />
                <field key="imgpath" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
        <field key="prodid" dbtype="int" precision="50" phptype="integer" null="false" default="0" />
                <field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
        <field key="pos" dbtype="int" precision="50" phptype="integer" null="false" default="0" />
                <field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
                <field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="id" collation="A" null="false" />
                </index>
                <aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="Product" class="Catalog" local="prodid" foreign="id" cardinality="one" owner="foreign" />
                </object>
            <object class="ProdClass" table="prod_classes" extends="xPDOSimpleObject" >
                <field key="classname" dbtype="varchar" precision="255" phptype="string" />
        <field key="summary" dbtype="mediumtext" phptype="string" />
        <field key="shortname" dbtype="varchar" precision="255" phptype="string" />
        <field key="classimg" dbtype="text" phptype="string" />
        <field key="classpri" dbtype="tinyint" precision="5" attributes="unsigned" phptype="integer" null="false" default="0"/>
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="id" collation="A" null="false" />
                </index>
                </object>
         <object class="AccyClass" table="prod_accessory_classes" extends="xPDOSimpleObject" >
                <field key="classname" dbtype="varchar" precision="255" phptype="string" />
        <field key="classimg" dbtype="text" phptype="string" />
                <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                        <column key="id" collation="A" null="false" />
                </index>
                </object>
        </model>


          • 4172
          • 5,888 Posts
          you can try to add into the migxdb-settings

          Join Alias:
          ProductCategory

          Extra Connection Table:
          N o

          Check Resource:
          Yes

          Load Grid:
          auto


          This should list only items, which are in currently edited Category.

          And yes, you can of course also edit and add items in nested grids.
          Added items should automatically get the classid of the currently edited Category, if you've set up everything correctly.


            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 8274 ☆ A M B ☆
            • 222 Posts
            Quote from: Bruno17 at May 18, 2016, 12:34 PM
            you can try to add into the migxdb-settings

            Join Alias:
            ProductCategory

            Extra Connection Table:
            N o

            Check Resource:
            Yes

            Load Grid:
            auto


            This should list only items, which are in currently edited Category.

            And yes, you can of course also edit and add items in nested grids.
            Added items should automatically get the classid of the currently edited Category, if you've set up everything correctly.


            Would that be added to the productcatalog config (the one I want to embed) or the ProdClasses config (the one i want to embed INTO)?

            Tried it on the ProdClasses, and the formtab just gives an empty grid, so either I put it on the wrong config, or something is not set up correctly.

              • 4172
              • 5,888 Posts
              you put it to the productcatalog config, since you want to filter the productcatalog - items by classid
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 8274 ☆ A M B ☆
                • 222 Posts
                If there is already a Join Alias ('Images') on the config, would it be a comma separated list of join aliases? so Images, ProductCategory?

                thanks
                jason
                  • 4172
                  • 5,888 Posts
                  no, the Join Alias is the one, which connects to the parent grid, in this case the Category, and can be only one alias.

                  If you have another grid inside the product for images, you would fill the joinalias in the images - setup

                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 8274 ☆ A M B ☆
                    • 222 Posts
                    Got to set up. A few further questions:
                    on the Product grid (productcatalog config, or Catalog object class), I have a column in my grid that calls to the category the product is assigned to (ProductCategory_classname).
                    When I pull this grid into the Category config, that column is blank (it is populated in the Catalog view). Is there a way to either remove this column ONLY in the Category config OR is there a way to make it pull the Category name in both configs (Catalog, which is Joined to Category, and Category config)?

                    Also, is there a how to on the renderPositionSelector or how to set the sorting order of products in a MIGX grid? I have been working with it and it doesn't seem to save the new ordering.

                    Thanks
                    Jason
                      • 4172
                      • 5,888 Posts
                      There is a way to add/change/remove columns and other settings dynamically, depending of request-parameters.
                      You will need a php-config-file with the name_of_your_config.config.inc.php
                      Examples:
                      https://github.com/Bruno17/migxmultilang/blob/master/core/components/migxmultilang/migxconfigs/mml_formtabs.config.inc.php
                      https://github.com/Bruno17/migxRecipes/blob/master/core/components/migxrecipes/migxconfigs/migxrecipes_recipes.config.inc.php
                      https://github.com/Bruno17/MIGX/blob/master/core/components/migx/configs/migxconfigs.config.inc.php

                      But why not, just create two different configs.

                      Did you check the Function this.handlePositionSelector under the 'Handlers' - tab?
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!