0

I have tried with API: /rest/V1/categories/3 get that give the only id of child category not name etc.

get response like : [children] => 4,5

not come: children_data

2 Answers 2

1

Give a try on the below one

http://www.domain.com/rest/V1/categories/list?searchCriteria[filterGroups][0][filters][0][field]=parent_id&searchCriteria[filterGroups][0][filters][0][value]=3&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

field will be field name(parent_id)

value will be parent category id(3)

conditionType will be an operator (eq)

Response will be as follows:

{
  "items": [
    {
      "id": 4,
      "parent_id": 3,
      "name": "string",
      "is_active": true,
      "position": 3,
      "level": 3,
      "children": "",
      "created_at": "2020-04-23 11:08:14",
      "updated_at": "2020-04-23 11:08:14",
      "path": "1/2/3/4",
      "available_sort_by": [],
      "include_in_menu": true,
      "extension_attributes": {},
      "custom_attributes": [
        {
          "attribute_code": "is_anchor",
          "value": 1
        }
      ]
    }
  ],
  "search_criteria": {
        "filter_groups": [
            {
                "filters": [
                    {
                        "field": "parent_id",
                        "value": "3",
                        "condition_type": "eq"
                    }
                ]
            }
        ]
  },
  "total_count": 1
}

Ref. https://devdocs.magento.com/swagger/index.html#/catalogCategoryListV1/catalogCategoryListV1GetListGet

0

I have found api belowed:

http://www.domain.com/rest/V1/categories?rootCategoryId=3

With this you can give any parent category id to parameter : rootCategoryId

And can get response like:

stdClass Object
(
    [id] => 3
    [parent_id] => 2
    [name] => 
    [is_active] => 
    [position] => 1
    [level] => 2
    [product_count] => 
    [children_data] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 4
                    [parent_id] => 3
                    [name] => 
                    [is_active] => 
                    [position] => 1
                    [level] => 3
                    [product_count] => 
                    [children_data] => Array
                        (
                        )

                )

            [1] => stdClass Object
                (
                    [id] => 5
                    [parent_id] => 3
                    [name] => 
                    [is_active] => 
                    [position] => 2
                    [level] => 3
                    [product_count] => 
                    [children_data] => Array
                        (
                        )

                )

        )

)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.