How to get Sub Category details by parent id Magento 2?

Get Sub Category (Child category) Collection details by the Parent Category id in Magento 2.

Using Parent Category Id, You can explore all the children category with deep level Or You can retrieve id by Current Category

When you check the Magento Open source sample data, You can see Men Category has direct two-child categories, Tops, and Bottoms at level 3 and both have other subcategories (Jacket, Tees, Pants, Shorts, etc) at level 4.

Using a given code snippet, you can retrieve all the subcategories of the parent without depends on the level type.

Call Block Class methods in the template,

You can get all the subcategory details by the given approach.

The output will display all the Child Category of the Specific Parent Category with name, URL, status, and id.

You can also read Get Category Collection Per Store level in Magento 2.

Leave a Reply