cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove Root Cateogry

How to remove Root Cateogry

Hello Everyone.

I have magento site running for past 4 years. by mistake admin added a root category and this caused the main category of the site to disappear from front page. problem I have is this ..

I can not remove it .. there is no delete button in admin section to remove it .

I was not able to move it around, directly from database , I changed its Level , and now I can move it around but still can not remove it . odd part is that , this category has a ID ( 2 ) . and because of its hierarchy if i change my store view ( i have multiple language ) keeps showing this category only and non of the categories are visible .

please let me know how I can fix this issue.

 

Thanks.

2 REPLIES 2

Re: How to remove Root Cateogry

Got it fixed. issue was root category was renamed and managed to correct it .

Thanks.

Re: How to remove Root Cateogry

To resolve this issue with the root category in Magento, follow these steps:

  1. Check the Store Configuration:

    • Go to Stores > Settings > Configuration.
    • Under General > Web, ensure that the correct category is set for the default store view. You might need to switch the root category to the original one that you were using before.
  2. Change Category Assignment in Store View:

    • Go to Stores > All Stores.
    • Click on your store and then on the Store View associated with it.
    • Under Root Category, select the correct category you want to display.
  3. Reassign Products to the Correct Categories:

    • Go to Catalog > Categories.
    • Find the correct root category.
    • Ensure that all the subcategories and products are assigned correctly to this root category.
  4. Check Database for Root Category ID:

    • If you've already manually changed the level in the database, ensure the changes are consistent. Run queries to check for any discrepancies in category levels and parent-child relationships.
    • Run the following SQL query to check if any child categories are incorrectly assigned to the new root:
      sql
       
      SELECT * FROM catalog_category_entity WHERE parent_id = 2;
    • Update or reassign categories if necessary.
  5. Clear Cache and Reindex:

    • After making changes, clear your Magento cache by going to System > Cache Management and refresh the cache.
    • Also, reindex the data by running the indexing commands from the Magento CLI:
      bash
       
      php bin/magento indexer:reindex
  6. Backup and Try to Delete via Database:

    • If there is no delete button in the admin, you can delete the category from the database. Before doing so, ensure you have a full database backup.
      sql
       
      DELETE FROM catalog_category_entity WHERE entity_id = 2;
    • After deletion, clear the cache again and check your store.

If you’re still facing issues, it’s recommended to contact a Magento developer to assist, as working directly with the database can sometimes cause unintended consequences.