I want to show all categories, even if they have no products in them.
How can I achieve something like this?
I believe that you'll need to override the
Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml template. Here is the relevant code:
<?php foreach ($block->getFilters() as $filter): ?> <?php if (!$wrapOptions): ?> <strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?php /* @escapeNotVerified */ echo __('Shopping Options') ?></strong> <dl class="filter-options" id="narrow-by-list"> <?php $wrapOptions = true; endif; ?> <?php if ($filter->getItemsCount()): ?> <dt role="heading" aria-level="3" class="filter-options-title"><?php echo $block->escapeHtml(__($filter->getName())) ?></dt> <dd class="filter-options-content"><?php /* @escapeNotVerified */ echo $block->getChildBlock('renderer')->render($filter); ?></dd> <?php endif; ?> <?php endforeach; ?>
I believe that this line is what you will want to remove:
<?php if ($filter->getItemsCount(): ?>. Obviously, override the core file, don't edit it directly.
If you have any questions, please let me know!