Hiding empty categories?

Hi!

Litium version: 6.1.1

We have multiple sites which share an assortment, but we want to limit some sites to certain types of products. These products may be in multiple categories, and we want to avoid manual work of publishing the correct categories for this site. We don’t want to show empty categories.

So I’m thinking one approach could be to only show categories that has published products or sub-categories with published products. Is there an easy way to achieve this?

In NavigationController, I was thinking I might be able to do my own filtering here.

Finally an option would be having some kind of task or similar that loops through all categories and publishes accordingly. Looks like I would be able to use PublishRecursive from the LitiumDemoHelper repo (but adapt to Litium 6 then). However, then I must make sure to run it after product changes, so the first approach might be better, unless it causes performance issues.

Is there any specific approach you would recommend as the Litium way?

Litium version: 6.1.1