Magento module Disable Empty Categories
New, improved version 2.3.0 is adding cronjob that will frequently deactivate categories with no products or activate categories with products. You can also still block changing category activity with attribute.
New version comes also with support for Lesti FPC (free, popular and really good Magento full page cache)! When some categories activity has changed than Lesti cache will refresh.
Don't let Your customers see famous text "There are no products matching the selection." - hide categories automatically when it will become empty!
With this module You can automatically hide categories that are empty. After install You will see configuration in System -> Configuration -> JRD Modules -> Disable Empty Categories. There You can enable hiding and set cache time to refresh (in seconds). It has own cache to prevent checking every time all categories products count. You can separately manage this cache in System -> Configuration -> Cache Management
Category will be visible again automatically (sometimes it will require cache refresh or wait for auto refresh of it's own cache) when it will get some visible products.
Categories are not disabled (no changes in category attributes "Is active" or "Include in Navigation Menu"), they are just hidden on frontend from every places where it is visible as collection (navigation menu, layered navigation and others).
Module counts only really visible products so category will be hidden when it will have only out of stock products or not visible indyvidually.