I want to get all categories of the specific category for that I tried
public function categoryHide()
{
$data = $this->arrayData();
$save = array();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
$categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');// Instance of Category Model
foreach($data as $test)
{
$category = $categoryFactory->create()->load($test);
// $parentCategories = $category->getParentCategories();
$childrenCategories = $category->getChildrenCategories();
foreach ($childrenCategories as $cat){
$save[] = $cat->getId();
}
}
return array_merge($data,$save);
}
}
This code is working perfectly for the Gear but if we tried to get the Ids of the Women or men category it will return only 2 children
it will only return the ids of tops and bottoms not there further children eg for women its category is 20 and tops category is 21 and bottoms category is 22 its only return there values not further children of tops and bottom. now I want to get all the child categories ids. Thanks in advance