I've been playing with the Catalog classes for a while, deleting and importing root categories, subcategories, stores and store groups, and I just discovered that every time I delete a root category the root catalog children count is decreasing.
I get this using $rootCatalog->getChildrenCount()
and it has now reached -249.
I must have done something dirty somewhere in my process, but I cannot find the source of this strange behavior.
This is the way I create root categories :
public function createRootCategory($name)
{
$parentCategory = $this->_categoryFactory->create()->load(\Magento\Catalog\Model\Category::TREE_ROOT_ID);
$category = $this->_categoryFactory->create();
$category->setPath($parentCategory->getPath());
$category->setStoreId(0);
$category->setName($name);
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setParentId(\Magento\Catalog\Model\Category::TREE_ROOT_ID);
$category->save();
return $category->getId();
}
Do you have any clue about the source of this behavior?
Do you know if it may impact Magento in any way?
How do I solve this?