App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
I am currently using the Trade theme and the Shopify Search & Discover app. I am trying to prevent search from including variants when searching. For clarification, searching "silver" shows every single painting because they all have silver frame variants. When clicking on it, it has one of the silver frames pre-selected instead of the default unframed option. Is there a way to change this behavior? Thanks.
One way to achieve this would be to add title: to the name parameter of the search form in main-search.liquid and header-search.liquid. This would limit the search term to the Product, Page or Blog title only excluding product variants from the results.
This wouldn't stop the results from showing in predictive search if you're theme uses them. I've not had time to dig into how that works, but i'm sure it would be something that could be done if needed.
Hope this helps
Simon
Upon further testing this solution may not be producing the desired result.
A current work around is to use an unless statement within the search results for loop targeting the product variant title. This successfully filters the displayed results, however, it can leave ghosted products which will continue to be paginated for larger result sets. I'm yet to find a neat solution to that, but I'll continue to work on it.
{%- for item in search.results -%}
{% assign downcaseTerms = item.selected_or_first_available_variant.title | downcase %}
{% unless downcaseTerms contains search.terms %}