Megan
Megan

Reputation: 11

Excluding products from shopify search

I am trying to exclude certain products with a specific tag. I was able to exclude products using {% unless result.tags contains 'wholesale' %} on the search page, but having trouble with the search header. The template I have been modifying is using the raw tag. Anyone got any suggestions?

 {% raw %}
          {{#if has_results}}
            <ul class="header-search__products grid">
              {{#each results}}
                <li class="grid__cell 1/3--handheld-and-up 1/4--desk">
                  <div class="product-item product-item--push">
                    {{#if on_sale}}
                      <div class="product-item__labels labels"><span class="label label--on-sale">{{@root.on_sale_label}}</span></div>
                    {{/if}}

                    <figure class="product-item__image-container">
                      <a href="{{url}}" class="product-item__link">
                        <img class="product-item__image " src="{{image}}" alt="{{image_alt}}">
                      </a>
                    </figure>

                    <div class="product-item__info">
                      <h3 class="product-item__title">
                        <a href="{{url}}" class="link">{{title}}</a>
                      </h3>

                      {{#if on_sale#}}
                        <span class="product-item__price product-item__price--new" data-money-convertible>{{price}}</span>
                        <span class="product-item__price product-item__price--old" data-money-convertible>{{compare_at_price}}</span>
                      {{else}}
                        <span class="product-item__price product-item__price--new" data-money-convertible>{{price}}</span>
                      {{/if}}
                    </div>
                  </div>
                </li>
              {{/each}}
            </ul>

            <a href="{{results_url}}" class="header-search__see-more button button--secondary" data-results-count="{{results_count}}">{{results_label}}</a>
          {{else}}
            <p class="header-search__no-results h4">{{results_label}}</p>
          {{/if}}
        {% endraw %}

Upvotes: 1

Views: 613

Answers (1)

miniscript
miniscript

Reputation: 34

Thankfully, it’s pretty easy to hide a product from your shop’s search. It involves adding some custom metadata.

This is the data you want to add:

"namespace" : "seo" 
"key" : "hidden"
"value" : 1
"value_type" : "integer"

Upvotes: 1

Related Questions