Search code examples
pimcorepimcore-v5

Pimcore 5: Is there a way to control allowed hierarchy of data objects?


Assume if have the following structure of pimcore 5 data objects:

Products (folder)
    Category A (custom class 'category')
        Category AB (Custom class 'category')
            Product A (Custom class 'product')
            ...
    Category B (custom class 'category')
        Product B (Custom class 'product')
Settings (folder)
    ...

By default the admin can add any class anywhere in the data objects area of pimcore, so in theory he can add a product under the the folder 'Settings', or a category under a product, but i want to prevent this, so he only can add 'category' in the products folder or another 'category', and so he only can add 'product' within a 'category' parent.

Is there a way to configure such a 'allowed child classes' system for the pimcore 5 data objects?

EDIT

With 'a way to configure' i do not necessary mean some solution provided by the admin interface, a solution requiring php coding is fine too.


Solution

  • The easiest way would be to use Custom Views (https://pimcore.com/docs/5.0.x/Objects/Object_Classes/Class_Settings/Custom_Views.html). Unfortunately, this would require separate panels for Settings and Products folder.

    If you want this behaviour in single Objects panel, you'd have to code in PHP and in ExtJS. You'll need to override pimcore.object.tree.onTreeNodeContextmenu method in web/pimcore/static6/js/pimcore/object/tree.js.