For some products I am using the size "One Size". I do not want that this is visible within the filter menu. Other sizes, like S, M, L, etc. should be visible of course. I do not want to create a new attribute that I a just will use for the "One Size" products. Because al those sizes should be within 1 attribute. How can I disable just the size "One Size" from the filtermenu?
Try below steps:
It may help!
Problem solved? Please click on 'Kudos' & Accept as Solution!
Hello @alexander_jorda
As per my understanding you want to hide specific value of attribute from layer navigation, You can edit this file and add a condition for that attribute value :
/app/design/frontend/{package}/{theme}/template/catalog/layer/view.phtml
let us know if it worked.
You can add some code customization to hide specific size options that you don't want to show in layered navigation. You can use below a simple way to achieve this.
First Override file below:
vendor\magento\module-layered-navigation\view\frontend\templates\layer\filter.phtml
to
app\design\frontend\iksula\default\Magento_LayeredNavigation\frontend\templates\layer\filter.phtml
Update your code changes accordingly in filter.phtml file
Add your condition as below:
if($filterItem->getLabel() == "One Size") : continue;
File changes for reference:
<ol class="items"> <?php foreach ($filterItems as $filterItem) : ?> /* Custom Changes Start */ <?php if($filterItem->getLabel() == "One Size") : continue; ?> /* Custom Changes End */ <li class="item"> <?php if ($filterItem->getCount() > 0) : ?> <a href="<?= $block->escapeUrl($filterItem->getUrl()) ?>"> <?= /* @noEscape */ $filterItem->getLabel() ?> <?php if ($this->helper(\Magento\Catalog\Helper\Data::class)->shouldDisplayProductCountOnLayer()) : ?> <span class="count"><?= /* @noEscape */ (int)$filterItem->getCount() ?><span class="filter-count-label"> <?php if ($filterItem->getCount() == 1) : ?> <?= $block->escapeHtml(__('item')) ?><?php else : ?> <?= $block->escapeHtml(__('item')) ?><?php endif;?></span></span> <?php endif; ?> </a> <?php else :?> <?= /* @noEscape */ $filterItem->getLabel() ?> <?php if ($this->helper(\Magento\Catalog\Helper\Data::class)->shouldDisplayProductCountOnLayer()) : ?> <span class="count"><?= /* @noEscape */ (int)$filterItem->getCount() ?><span class="filter-count-label"> <?php if ($filterItem->getCount() == 1) : ?><?= $block->escapeHtml(__('items')) ?><?php else : ?><?= $block->escapeHtml(__('items')) ?><?php endif;?></span></span> <?php endif; ?> <?php endif; ?> </li> /* Custom Changes Start */ <?php endif; ?> /* Custom Changes End */ <?php endforeach ?> </ol>