I am trying to get a level 2 category list. I got all level 2 categories but I am also getting 2 unknown categories which are not in backend. This is weird. Here is my code
public function getShopCategories()
{
$objectManagerr = \Magento\Framework\App\ObjectManager::getInstance();
$categoryFactory = $objectManagerr->create('Magento\Catalog\Model\ResourceModel\Category\CollectionFactory');
$categories = $categoryFactory->create()
->addAttributeToSelect('*')
->addAttributeToFilter('is_active', 1) //only active categories
->addAttributeToFilter('include_in_menu', 1)
->addAttributeToFilter('level', array('eq'=>2));
return $categories;
}
I reindexed and checked for different store views but not getting these categories.
unknown
category is present?e
.*, IF(at_name.value_id > 0, at_name.value, at_name_default.value) ASname
FROMcatalog_category_entity
ASe
INNER JOINcatalog_category_entity_varchar
ASat_name_default
ON (at_name_default
.entity_id
=e
.entity_id
) AND (at_name_default
.attribute_id
= '41') LEFT JOINcatalog_category_entity_varchar
ASat_name
ON (at_name
.entity_id
=e
.entity_id
) AND (at_name
.attribute_id
= '41')