We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39404
    • 175 Posts
    stalemate resolution associate Reply #1, 11 years, 4 months ago
    Description of Problem:
    When creating a transport package, if I have nested Categories (i.e. categories under categories), category parents are not updated during the install, even if xPDOTransport::PRESERVE_KEYS is set to `false`.

    Steps to Reproduce:
    Create a package which has categories as follows:
    Category Id, Category Name, Parent
    1 Top Level 0
    2 First Child 1
    3 Another Child 1

    Set xPDOTransport::PRESERVE_KEYS = false when adding the categories to the vehicle.

    On a sample target site, create a category and call it anything other than "Top Level".

    Import the package, and your categories will show as follows (when querying the database):
    Category Id, Category Name, Parent
    1 Test Category 0
    2 Top Level 0
    3 First Child 1
    4 Another Child 1

    Expected Outcome:
    Category Id, Category Name, Parent
    1 Test Category 0
    2 Top Level 0
    3 First Child 2
    4 Another Child 2
    (i.e. categories 3 and 4 have a parent of 2, not 1).

    Workaround:
    Set xPDOTransport::PRESERVE_KEYS = true when adding the categories to the vehicle. This isn't a solution because the output you would see is:
    Category Id, Category Name, Parent
    1 Top Level 0
    2 First Child 1
    3 Another Child 1
    So in essence, you have clobbered the existing category.

    Another possible workaround is to simply not use nested categories, but that isn't my first preference as I like the tree structure.


    • MODX Version: 2.5.5
    • PHP Version: 5.3.8
    • Database (MySQL, SQL Server, etc) Version: SQL Server 2008 R2
    • Additional Server Info: This server likes long walks on the beach.
    • Installed MODX Add-ons: Wayfinder
    • Error Log Contents: No error generated

    Thanks in advance for all comments. As well, this is hardly a burning issue for me, but I raise it all the same.

    This question has been answered by jobkingori. See the first response.

    • discuss.answer
      • 14372
      • 49 Posts
      Check Splittingred's response to another similar issue ...

      How can we create subcategories with modx package?
      http://forums.modx.com/thread/37958/how-can-we-create-subcategories-with-modx-package#dis-post-214348

      He says ...

      At this time, to my knowledge, any levels more than 2 deep for RELATED_OBJECTS wont work. OpenGeek can give you more information on that.

      Then someone else gives a workaround (which is what I'll do when I get to it) suggesting to use resolvers instead ... to do that work. There you can use normal code etc ... (which can be cumbersome ...)

      Thats exactly what I have done, I am using php resolvers to associate objects together, seemed to fix it but for the size of my package its getting pretty involved.

      I know this doesn't fix your problem entirely, but sometimes its good to know from the word go that it's not possible so that you save on time ...
        • 39404
        • 175 Posts
        stalemate resolution associate Reply #3, 11 years, 3 months ago
        Hi King'ori,

        Thanks very much for the reply! It may not necessarily be the answer I would have intuitively thought, but at least it's more than I had before.