From b47f9b17c48c9d21809b0485559471773c2c97b4 Mon Sep 17 00:00:00 2001 From: Ji Sohn Date: Mon, 26 Feb 2024 11:00:03 -0500 Subject: [PATCH] fix: search result 500 --- .../components/async/search-results.html.twig | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/theme/components/async/search-results.html.twig b/theme/components/async/search-results.html.twig index 7ad055d..f5dc5ff 100644 --- a/theme/components/async/search-results.html.twig +++ b/theme/components/async/search-results.html.twig @@ -15,25 +15,28 @@ class="search-results__category-list-wrapper col" col-xs-12 col-sm-12 col-md-3 > + {% set item_categories = [] %} + {% for item in items %} + {% set category = item.categories[0] %} + {% set categoryExists = item_categories|filter((c) => c.square_online_id == category.square_online_id) %} + {% if category.square_online_id and categoryExists == false %} + {% set item_categories = item_categories|merge([category]) %} + {% endif %} + {% endfor %}

- {% if query is not defined %} + {% if (query is not defined) and (item_categories is not empty) %} {{ 'components.search.suggested_searches'|localize }} - {% else %} + {% elseif query is defined %} {{ 'components.search.top_results'|localize }} {% endif %}