0

I want to show all categories, even if they have no products in them.

How can I achieve something like this?

Empty Category Example

0

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!

  • All that does is remove the entire "category type" from the block. I want the category children that are 0 to be visible. – Cam Dec 17 '16 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.