How To Get Current Magento 2 Category Name Programmatically

How to get current Magento 2 category name from Block class

To retrieve current Magento 2 category name from Block class, you need load “Magento\Framework\Registry” object first and then call “registry(‘current_category’)” method to get current category object. Here is the example.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$registry = $objectManager->get(‘\Magento\Framework\Registry’);
$category = $registry->registry(‘current_category’);
$categoryName = $category->getName();
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments