Magento doesn't show all the categories in admin

浪尽此生 提交于 2019-12-04 13:54:44

After reading Joseph answer i've tried to search for errors in catalog_category_entity and founded that all the categories in my tree has level 1 or 2 except for the categories that doesn't appear that have level 7. The strange things is that level 7 is the correct level for those category anyway i think that the problem is that Magento found a category with level 2 and it direct children has lavel 7 and it doesn't recognize those category as children for the father category.

I've changed level of the children to 2 and everything seems to work.

Why all the category in my tree has level 1 ? i don't know ...

you want to go into table catalog_category_entity

run the following SQL query:

UPDATE catalog_category_entity SET children_count =
(SELECT COUNT(*) FROM
(SELECT * FROM catalog_category_entity) AS table2
WHERE path LIKE
CONCAT(catalog_category_entity.path,"/%"));

Did you create the categories programmatically (as opposed to using the admin interface)? As is often the case in Magento, when some value is missing or incorrect in the database, entries may not show up at all. If this is the case, please take a look at a "good" category record in the database and make sure that the missing categories follow the correct conventions.

Hope that helps!

Thanks, Joe

In my case I imported all of the categories and assigned 'level' as its position in the tree. Maybe that isn't what it's for, because setting all the categories to a level of 2 worked beautifully and kept my tree intact.

Code I used to put all levels to 2 after setting it incorrectly:


    foreach ($categories as $category) {
        $category = $category->load($category->getId());

        $level = $category->getLevel();

        if($level > 2) {
            $category->setLevel(2);
            $category->save();
        }

    }

For the mentioned cases, this query could have helped:

select c.entity_id cid, p.entity_id pid
from 
  catalog_category_entity c
  inner join catalog_category_entity p on c.parent_id = p.entity_id
where c.level != p.level+1

It didn't help me with my categories, though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!