<?php $helper = $this->helper('\Magento\Catalog\Helper\Data'); ?>
<ol class="items">
    <?php foreach ($filterItems as $filterItem): ?>
        <?php
            $checked = ''; 
            if(!$filterItem->getActive()) {
                $url = $filterItem->getUrl();
            } else {
                $checked = 'checked';
                $url = $filterItem->getRemoveUrl();
            }
             
        ?>
        <li class="item">
            <a class="mgs-ajax-layer-item" href="<?php echo $block->escapeUrl($url) ?>">
                <?php /* @escapeNotVerified */ echo $filterItem->getLabel() ?>
                <?php if (!$filterItem->getActive() && $filterItem->getCount() > 0): ?>
                    <span class="count mgs-option-count">
                    <?php /* @escapeNotVerified */ echo  $filterItem->getCount() ?></span>
                <?php endif; ?>
            </a>
			 <div class="mgs-filter-item-checkbox">
                <input type="checkbox" class="mgs-layered-checkbox" <?php echo $checked ?>>
                <div class="mgs-content"></div>
            </div>
        </li>
    <?php endforeach ?>
</ol>
