App reviews, troubleshooting, and recommendations
Hello,
i am using dawn theme, i want search result as per meta fields of products. added code with predictive-search.liquid, but its not working proper, here is the code, can anyone suggest please.
{%- if predictive_search.performed -%} <div id="predictive-search-results"> {%- if predictive_search.resources.products.size > 0 -%} <div class="collage-list test"> {%- assign displayed_colleges = '' -%} {%- for collection in predictive_search.resources.products limit: 15 -%} {%- assign college_name = collection.metafields.custom.colleges_name.value -%} {%- assign college_url = collection.metafields.custom.colleges_name.value | handle -%} {%- unless displayed_colleges contains college_name -%} <div class="collage-list-item"> <a class="collage-list-item_inner" href="collections/{{ college_url }}"> <div class="collage-list-item_img"> {% include 'college-icon' %} </div> <span class="collage-list-item_name">{{ college_name }}</span> </a> </div> {%- assign displayed_colleges = displayed_colleges | append: college_name | append: ',' -%} {%- endunless -%} {%- endfor -%} </div> {% comment %} <a class="view_all" href="/search?q={{ predictive_search.terms }}&options[prefix]=last"> {{- 'general.search_banner.view_all' | t -}} </a> {% endcomment %} {% else %} <p class="empty_data text-center">{{ 'general.search_banner.empty' | t }}</p> {%- endif -%} </div> {%- endif -%}
Hi @Krishna12
Here's a revised version of your loop, with some of the above points in mind:
{%- for product in predictive_search.resources.products limit: 15 -%}
{%- if product.metafields.custom and product.metafields.custom.colleges_name -%}
{%- assign college_name = product.metafields.custom.colleges_name.value -%}
{%- assign college_url = college_name | handleize -%}
{%- unless displayed_colleges contains college_name -%}
<div class="collage-list-item">
<a class="collage-list-item_inner" href="{{ college_url | url_for_type: 'collection' }}">
<div class="collage-list-item_img">
{% include 'college-icon' %}
</div>
<span class="collage-list-item_name">{{ college_name }}</span>
</a>
</div>
{%- assign displayed_colleges = displayed_colleges | append: college_name | append: ',' -%}
{%- endunless -%}
{%- endif -%}
{%- endfor -%}
If these adjustments don't resolve the issue, you should provide more details about what specifically isn't working as expected.
Thanks for the reponse. i have tried your given solution. but its not working for some reason, sharing you more details.
attached ss of meta field that i am using for search.
https://www.loom.com/share/dd91f2119df04d8480e11079ac1080a9
Video attached for result of search.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025