3
votes

we have a magento store with various categories one inside another (subcategory). Our problem is that when we enter in the admin to manage categories in the category tree on the left, some of our categories that has subcategories looks correctly with the plus (+) icon on the left but when we try to expand the category magento doesn't display any item.

The ajax call point to this url:

index.php/admin/catalog_category/categoriesJson/key/09b218741dce69171825fdbf4954855d/?isAjax=true

and it returns an empty array without throwing any error. Frontend displays all the categories correctly.

Magento version 1.4.2.1

Any idea ?

5
Got the same problem. Now Magento is apparently looking for id POST parameter, and I'm only getting form_key.Victor Sergienko

5 Answers

3
votes

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,"/%"));
2
votes

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 ...

1
votes

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

1
votes

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();
        }

    }

0
votes

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.