cancel
Showing results for 
Search instead for 
Did you mean: 

Remove size attribute from filter

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Remove size attribute from filter

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?

3 REPLIES 3

Re: Remove size attribute from filter

Hi @alexander_jorda 

 

Try below steps:

  1. Step 1: From the Admin Panel, choose Stores > Attributes > Product.
  2. Step 2: Find the specific attribute, click on the attribute and choose Delete button to delete this attribute.

It may help!

Problem solved? Please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: Remove size attribute from filter

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.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Remove size attribute from filter

Hi @alexander_jorda 

 

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>

 

Hope this helps you!
Problem Solved! Click Kudos & Accept as Solution!