I am using Magento 2.3.1 and the pearl theme. My site has many different categories and I wanted to know if there is a way to have magento automatically remove categories that don't have product in them from the menu. I don't need them to be "disabled", just not visible.

Preferably also by level, as I use some of the root categories for other things besides products (due to brand licensing). I have looked at this question:
here. However, that looks like it's Magento 1.7 and it also seems like a lot of work for something like this.

1 Answer
1

One route would be template work with additional queries to work out which category to hide based on visible product count. The other approach would be a console script which goes through categories and sets empty ones to false (otherwise true) for the visible in menu category attribute.