Layer Navigation item Dropdown in Magento 2

Just copy

vendor/magento/module-layered-navigation/view/frontend/templates/layer/filter.phtml

to your theme example on

app/design/frontend/<Vendor_Name>/<Theme_Name>/Magento_LayeredNavigation/templates/layer/filter.phtml

Replace Code with following

<select name="layered-nav-select" class="layer_nav_filter">
    <option selected="selected" value="#">Please Select</option>
   <?php foreach ($filterItems as $filterItem): ?>
        <?php if ($filterItem->getCount() > 0): ?>
            <option value="<?= $block->escapeUrl($filterItem->getUrl()) ?>">
               <?= /* @escapeNotVerified */ $filterItem->getLabel() ?>
               <?php if ($this->helper('\Magento\Catalog\Helper\Data')->shouldDisplayProductCountOnLayer()): ?>
                    <span class="count"><?= /* @escapeNotVerified */ $filterItem->getCount() ?>
                        <span class="filter-count-label">
                        <?php if ($filterItem->getCount() == 1):?>
                            <?= /* @escapeNotVerified */ __('item') ?>
                        <?php else:?>
                            <?= /* @escapeNotVerified */ __('items') ?>
                        <?php endif;?>
                        </span>
                    </span>
               <?php endif; ?>
            </option>
        <?php else:?>
            <?= /* @escapeNotVerified */ $filterItem->getLabel() ?>
            <?php if ($this->helper('\Magento\Catalog\Helper\Data')->shouldDisplayProductCountOnLayer()): ?>
                <span class="count"><?= /* @escapeNotVerified */ $filterItem->getCount() ?><span class="filter-count-label">
                    <?php if ($filterItem->getCount() == 1):?><?= /* @escapeNotVerified */ __('item') ?><?php else:?><?= /* @escapeNotVerified */ __('items') ?><?php endif;?></span></span>
            <?php endif; ?>
        <?php endif; ?>
   <?php endforeach ?>
</select>

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.