commercetools

How to change sub-category to root category in CommerceTools


I need to change a sub-category of my project so that it is located at the root of the categories and not like now that it is a sub-category of another.

I have tried the action "changeParent", but it requires me to put the id of another category and does not support giving it an empty or null value.

I would not like to have to delete the category as it already has associated products.

Is there any other way to do it?

Thanks in advance.


Solution

  • It's not possible to unset a parent category.

    But you could recreate only the category you want to become a root category and change the parent of all children to the newly created category. But still you would have to assign these products to the new category.

    As a general advice I would always create an explicit root category and use this as the entry point in your application. First you could circumvent in this case the limitation to unset a parent category. And you can even have multiple trees for different applications (e.g. mobile, desktop) or prepare an updated category tree (e.g. winter/summer season)