Pergunta

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?

Foi útil?

Solução

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();

Outras dicas

Have you tried the following?

 $category->getChildrenCategories();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top