MAGENTO2

Get the product count by attribute(swatches) in filter option in magento 2

 \Magento\Swatches\Block\LayeredNavigation\RenderLayered::getOptionViewData
return [
    ‘label’ => $swatchOption->getLabel(),
    ‘link’ => $linkToOption,
    ‘custom_style’ => $customStyle,
    ‘count’ => $filterItem->getCount()
];
Magento/Swatches/view/frontend/templates/product/layered/renderer.phtml
<?php foreach ($swatchData[‘options’] as $option => $label): ?>
    <?php if(isset($label[‘count’])) {echo $label[‘count’];} ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − eleven =