Monday, May 16, 2011

Magento - what to do when someone deletes the root category

We all know users make errors. Even developers make errors. Last month, I had an extremely embarrassing mistake to admit to my boss - I'd deleted a live table. Thank goodness it wasn't something important.

Last week, someone deleted the Magento root category in a Magento install I provide services for.

It turns out this was easy to fix, but it took me a good hour to find!

So, the symptoms were:

  • No root category
  • No categories showing on the site
  • Couldn't create a new root
  • When I went to choose the root for the store in the config, the dropdown was blank!
  • The categories were still in the catalog_categories table.
So, the first step, is to find the store and check what the root category is. To do this, look at the core_store_group table. My root category was 2.

Now look at catalog_category_entity. Check the path of the root category (2 in this case).

Tada! All the categories had paths such as 1/2/3/42, whereas the #2 category had a path of "Default Category"!.

Changed the path to 1/2 and it fixed it.

All the forum posts I found at the Magento site were unhelpful, I've generally found the forums there to be mostly useless.


No comments:

Post a Comment