I want to get the subcategories of a main category using main category url.
I tried in this way in a function in my block.
$category = $this->_categoryFactory->create()->getCollection()
->addAttributeToFilter('url_key',$url_key);
I want to get the subcategories of a main category using main category url.
I tried in this way in a function in my block.
$category = $this->_categoryFactory->create()->getCollection()
->addAttributeToFilter('url_key',$url_key);
Get Category
$categoryCollection = $this->_categoryFactory->create()->getCollection()
->addAttributeToFilter('url_key',$url_key)->getFirstItem();
$childs = $categoryCollection->getChildrenCategories();
foreach ($childs as $child) {
echo $child->getUrlKey();
}