Tutorialsplane

Magento 2 get category Url


Magento 2 get category Url Path By Id: We can get category url from category object. Here in this tutorial, we are going to explain how you can get category url using category id.


Magento 2 get category Url Path By Id Example

You can get category url using category id simply as below-

Get Cetgory Url Example:

$categoryId = 5;
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId);
$url = $category->getUrl();