1

In layer navigation multiselect attribute not displayed. $filter->getItemsCount() in vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml always return zero.

<?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; ?>

My try

$filter have all the multiselect attribute but $filter->getItemsCount() return zero.

e.g)

$filter have brand attribute, category page have many products which have brand value however $filter->getItemsCount() return zero

please suggest nicer way to debug?

Note: I did reindex. All cahce are disabled. In admin, we enabled needed properties to display in Navigation.

1

Go to file:-

vendor\magento\module-catalog-search\Model\Layer\Filter\Attribute.php

There you can check public function apply

That can help you out in debugging. Another way of debugging is to use Xdebug. It is a good way of seeing how files are being used.

More info can be seen here:-

http://devdocs.magento.com/guides/v2.0/install-gde/docker/docker-phpstorm-debug.html

0

I don't have enough reputation to comment, so I'll suggest a few things with an answer.

Make sure the attribute in question is set to "filterable (with results)" or "filterable (no results)" in Use in Layered Navigation.

You might have mistakenly selected this option: Use in Search Results Layered Navigation

If all of your products have the same brand the brand filter won't show if filterable (with results) is selected.

So you might want to change this to filterable (no results) for testing purposes.

I would also recommend disabling 3rd party modules that might have changed the functionality of Layered navigation and check if that helps.

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.