Question

For now I'm getting category name.

This is my code:

app/code/Vendor/Module/view/frontend/templates/storecategories.phtml

<?php
        $categoryId = 65;
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $category = $_objectManager->create('Magento\Catalog\Model\Category')
            ->load($categoryId);
        $parent = $category->getName();
        echo $parent?>

What would be next steps to get current categories subcategories?

Était-ce utile?

La solution

Try This

 $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
 $categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');// Instance of Category Model
 $categoryId = 15; // YOUR CATEGORY ID
 $category = $categoryFactory->create()->load($categoryId);
 // Children  Categories
 $childrenCategories = $category->getChildrenCategories();

Autres conseils

Have you tried the following?

 $category->getChildrenCategories();
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top