How to hide specific products from search in Dawn 15

How to hide specific products from search in Dawn 15

modernmagic
Shopify Partner
13 0 3

I have found this code:

{% assign filtered_results = search.results | where_exp: "product", "product.tags contains 'exclude-from-search' == false" %}

 

I have tagged all the products that I do not want displayed in search results with "exclude-from-search".

 

I thought that this code should go in:  main-search.liquid

 

But I can't figure out where to put it.  Nothing has worked so far.

 

Replies 5 (5)

Alex485483
New Member
7 0 0

Hi  I think I can help with that.  If you're still having issues, feel free to share more details.

A2EE1686-7215-4835-AC34-401F83785BB9.jpeg

modernmagic
Shopify Partner
13 0 3
I’m looking for someone to tell me where to paste the code?

Guleria
Shopify Partner
4185 812 1168

Hello @modernmagic ,

 

The code will be used with the existing loop.  

Check the search template for similar loop

starts with 

{% for item in search.results %}
and ends with 
{% endfor %}


now here you have to apply the logic.

 

Regards
Guleria 

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

devcoders
Shopify Partner
1596 189 488

Hello @modernmagic 
Welcome to the Shopify Community! Please share your store URL and password (if it’s password-protected), so I can check and provide you with the exact solution.

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!

AnneLuo
Shopify Partner
1369 237 279

Hi, @modernmagic 

  1. Step-by-step:
    Go to Online Store > Themes > Edit Code
  2. Open sections/main-search.liquid (or templates/search.liquid, depending on your theme)

Look for a loop like:

{% for item in search.results %}


Replace it with:

{% assign filtered_products = search.results | where: "object_type", "product" %}
{% assign visible_products = filtered_products | reject: "tags", "exclude-from-search" %}

{% for product in visible_products %}
<!-- Render product card -->
{% render 'card-product', product: product %}
{% endfor %}

If you will unable to implement the same then I'm happy to do this for you, let me know.

Hope this helps! If yes then Please don't forget hit Like and Mark it as solution!

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me   

Buy Me A Coffee