Hi all!
I recently created a custom liquid search bar:
{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-search.css' | asset_url | stylesheet_tag }}
{%- if section.settings.enable_filtering or section.settings.enable_sorting -%}
{{ 'component-facets.css' | asset_url | stylesheet_tag }}
{%- endif -%}
{%- liquid
assign sort_by = search.sort_by | default: search.default_sort_by
assign terms = search.terms | escape
assign search_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by
-%}
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}
#
{%- if search.performed -%}
{{- 'templates.search.title' | t -}}
{%- else -%}
{{- 'general.search.search' | t -}}
{%- endif -%}
{%- if settings.predictive_search_enabled -%}
{%- endif -%}
{%- if search.performed -%}
{%- unless section.settings.enable_filtering or section.settings.enable_sorting -%}
{%- if search.results_count > 0 -%}
{{ 'templates.search.results_with_count_and_term' | t: terms: search.terms, count: search.results_count }}
{%- endif -%}
{%- endunless -%}
{%- if search.results_count == 0 and search.filters == empty -%}
{{ 'templates.search.no_results' | t: terms: search.terms }}
{%- endif -%}
{%- endif -%}
{%- if search.performed -%}
{%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' and search.filters != empty -%}
{%- endif -%}
{%- endif -%}
I noticed search bar was working well but I have noticed some issues since I implemented this search bar. The live version of the search bar is not working anymore. FYI, I do not know if this is related to the code above. Just mentioning it as it is something that was done around this time.
I recently uploaded roughly 800 products by scraping another website. They are all there in my backend and configured correctly. When I preview my website from the backend and use the search function it works fine. It displays everything correctly and the count is correct.
However, if I go to the live version online the search doesn’t work. When I search a very broad term like the brand name it shows no results. It does show a count on the page but that is also incorrect.
Even if I delete the custom liquid and revert back to original search bar the issue persists.
It is as though the search results on the live page are not in sync with what is on the actual website…
If I search a very specific full title, the search finds the correct product. I know because I deleted this product from the back end and it is not searchable anymore.
Everything else on the live website is correct and up tp date if I make any changes to the back end.
Any ideas what the issue may be?
Kind regards,