private function getChildrenCategories(CategoryInterface $category, $excludedCategories = [])
    {
        $storeId            = $category->getStoreId();
        $categoryCollection = $this->categoryCollectionFactory->create()->setStoreId($storeId);

        $categoryCollection->addIsActiveFilter()->addPathFilter(sprintf('%s/.*', $category->getPath()));

        if (((bool) $category->getIsVirtualCategory()) === false) {
            $categoryCollection->addFieldToFilter('is_virtual_category', '1');
        }

        if (!empty($excludedCategories)) {
            $categoryCollection->addAttributeToFilter('entity_id', ['nin' => $excludedCategories]);
        }

        $categoryCollection->addAttributeToSelect(['is_active', 'virtual_category_root', 'is_virtual_category', 'virtual_rule']);

        return $categoryCollection;
    }
private function getChildrenCategories(CategoryInterface $category, $excludedCategories = [])
    {
        $storeId            = $category->getStoreId();
        $categoryCollection = $this->categoryCollectionFactory->create()->setStoreId($storeId);

        $categoryCollection->addIsActiveFilter()->addPathFilter(sprintf('%s/.*', $category->getPath()));

        if (((bool) $category->getIsVirtualCategory()) === false) {
            $categoryCollection->addFieldToFilter('is_virtual_category', '1');
        }

        if (!empty($excludedCategories)) {
            $categoryCollection->addAttributeToFilter('entity_id', ['nin' => $excludedCategories]);
        }

        $categoryCollection->addAttributeToSelect(['is_active', 'virtual_category_root', 'is_virtual_category', 'virtual_rule']);

        return $categoryCollection;
    }
private function getChildrenCategories ( CategoryInterface $ category , $ excludedCategories = [ ] ) { $ storeId = $ category -> getStoreId ( ) ; $ categoryCollection = $ this -> categoryCollectionFactory -> create ( ) -> setStoreId ( $ storeId ) ; $ categoryCollection -> addIsActiveFilter ( ) -> addPathFilter ( sprintf ( '%s/.*' , $ category -> getPath ( ) ) ) ; if ( ( ( bool ) $ category -> getIsVirtualCategory ( ) ) === false ) { $ categoryCollection -> addFieldToFilter ( 'is_virtual_category' , '1' ) ; } if ( ! empty ( $ excludedCategories ) ) { $ categoryCollection -> addAttributeToFilter ( 'entity_id' , [ 'nin' => $ excludedCategories ] ) ; } $ categoryCollection -> addAttributeToSelect ( [ 'is_active' , 'virtual_category_root' , 'is_virtual_category' , 'virtual_rule' ] ) ; return $ categoryCollection ; }
Returns the list of the virtual categories available under a category.

@param CategoryInterface $category           Category.
@param array             $excludedCategories Category already used into the building stack. Avoid short circuit.

@return \Magento\Catalog\Model\ResourceModel\Category\Collection;
Returns the list of the virtual categories available under a category .