Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:31:48+00:00 2026-06-10T14:31:48+00:00

I want to implement something that would delete the empty categories and sub categories

  • 0

I want to implement something that would delete the empty categories and sub categories if there are no products in them.

There may be 100s of categories.So I don’t want to use backend for this.

I am in trouble please help me.

I am referring this link Hide Empty Categories but this is only hiding parent categories from navigation bar even if it’s sub categories have products in them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:31:50+00:00Added an answer on June 10, 2026 at 2:31 pm

    Here is one way to delete empty categories…

    $categoryCollection = Mage::getModel('catalog/category')->getCollection()
        ->addFieldToFilter('level', array('gteq' => 2))
    ;
    
    foreach($categoryCollection as $category) {
        if ($category->getProductCount() === 0) {
            $category->delete();
        }
    }
    

    This will delete the categories – not simply hide them


    EDIT

    To answer the following posted in a comment:

    "Could you please share a link of some tutorial or weblink.I am weak in creating custom modules". 
    

    see here

    You would be better just creating a script for this simple task. Here is a nice resource to explain how to bootstrap Magento for your script to run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement something with jquery, simple javascript and java but I don't
I want to implement something like Col3 = Col2 + Col1 in SQL. This
I want to implement something simple like /System/Workflows/Sample Workflow with the small addition of
I am learning OOP with python. I want to implement something like to display:
I want to implement in my webpage something similar to google search page. The
i want to implement a dynamic relation mechanism with python something like: a:=10 b:=30
for iOS 5.0 using ARC, here is something I want to implement and need
I want to do something like this: I tried to implement it by myself
In Safari and other browsers, there is a bar that would indicate the percentage
I would like to implement something equivalent to the unix command 'rm foo*' using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.