$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
$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
cat1 -- subCat1
ReplyDelete-- subCat2 -- subCat1
-- subCat2
-- subCat3
Hello,
If my current category is subCat3 then your code return subCat2 id.
but i want to get cat1 id. so how can we get it.
means i need root category id.