Now you get the list of categories by API, by request, like
http://api.brain.com.ua/categories/ ??
If yes, then it returns all categories
And tell me, please, you need another setting "Parent category"
- If the checkbox is not checked, do not load categories - tie all categories of the brain to the selected category, and those without a category (maybe there are such) just to the selected one.
- If there is a checkbox, then just fill in all the products in the specified category