Category Tree Not Showing In Magento Admin Product Edit Pages After Upgrade

Wednesday, 3. April 2013

I have come across this issue recently after an upgrade and site merging of two Magento stores in version 1.7.0.2.

The issues in the end came to be that the categories migrates from Site B to Site A somehow lost the Child_Count values in the catalog_category_entity table

To solve this particular problem I had to do the following. You will need access to database to implement this solution with IDE like PhPMyAdmin or something similar.

1. Create a temporary table containing count values
This step will depend on the path values on your database. For me, the Root category was of ID 340.. So all you need to do is to replace the 340 with your root category ID or the ID of the category you want to fix.

CREATE TABLE temp_category_child_count (entity_id INT(11), child_count INT(11));
INSERT INTO temp_category_child_count
SELECT parent_id, COUNT(entity_id) total  FROM `catalog_category_entity` WHERE path LIKE '1/340/%' GROUP BY parent_id ORDER BY parent_id;

2. Now move the counts to the entity table
This step will now move the children count values from the temp table back to the main category entity table.

UPDATE `catalog_category_entity` a, temp_category_child_count b 
SET a.children_count = b.child_count
WHERE a.entity_id = b.entity_id;

3. Finally refresh your Magento indexes
This is important step to ensure your Magento database is up to speed with your changes. The important index to refresh is the Category Flat Data

Hopefully now when you go to your Product Edit pages again, you will see your category tree nice and clear!

Enjoy!

Leave a Reply

You must be logged in to post a comment.