0

I am trying to get first level category from current category ID in my controller . For example- I have

  • Maincategory

    • SubCategory1

      • SubCategory2

        • SubChild1

        • SubChild2.

I want to access Maincategory in my controller whether my current catgeory id is SubChild1 or it's SubCategory1.

How can I do this?

1 Answer 1

0

Please try with add below code in your controller to get using your category id to get all parent categories..

$category = $categoryFactory->create()->load($categoryId);
$parentCategories = $category->getParentCategories();

Your Answer

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

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