Showing posts with label get parent category in magento 2. Show all posts
Showing posts with label get parent category in magento 2. Show all posts

Monday, 18 July 2016

magento 2 how to get parent category id current category

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
   $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
  $current_cat = $category->getId(); // current category id

  $parent_cat =  $category->getParentCategory()->getId(); // parent category id