Back to Top

Magento 2 – Get Parents and Children Categories From a Category

Updated 17 February 2026

If having an issue in getting parents and children categories from a category in Magento 2 then no need to worry about this.

We’ll explore here how to get parent and child categories in Magento 2 for a specific category using simple and effective methods.

<?php 
 $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
 $categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');// Instance of Category Model
 $categoryId = 15; // YOUR CATEGORY ID
 $category = $categoryFactory->create()->load($categoryId);
 // Parent Categories
 $parentCategories = $category->getParentCategories();
 // Children  Categories
 $childrenCategories = $category->getChildrenCategories();

?>

Hope this blog will help you.

Searching for an experienced
Magento 2 Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


4 comments

  • Prashant (Backarapper Blog)
    • Anuj Gupta (Moderator)
  • jafar
    • Anuj Gupta (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home