Website search results to return Collections?

Tourist
4 0 2

Hi there Geniuses

I originally asked this question on an older thread, but no reply there so thought I would ask you clever people if this is even possible on Shopify.

Returning Collections in search results would be useful on our store.  ‘Collections' are used as artist pages and the product tags determine which albums appear for the artist's collections.

So if someone searched an artist they currently would only get product results, but no artist information page.  This can only be navigated to as a collection.

Is there any work around for this or would anybody know how to do it?!

Thanks

Phil

0 Likes
Tourist
4 0 2

Bump!

Anyone?

0 Likes
Shopify Expert
9807 92 1560

As far as I know collection results are not returned in the standard storefront search. You could try and build you own rudimentary collection searcher but it might not be terribly efficient. Another option would be to create as many pages as there is collections - pages can be searched. If you have 100's of collections you'd want to automate the creation of those pages.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Shopify Expert
104 0 21

super old post but thought I would add my recommendation here. If you dont want to add a paid search app, and your template doesn't use an AJAX search, you can add something like this to your search.liquid file (depending on your template you may need to adjust classes / div structure)

Add this to the top of the search.liquid file to see if there are any collections that match the search terms (and add to the results count if there are)

 

{% assign searchThis = search.terms | escape | lowercase %} 
{% assign collectionCount = 0 %}

{%- for collection in collections -%}
{%- capture collectionKeywords -%}{{ collection.title | lowercase }} {{ collection.description | handleize | replace: '-' ,' ' }}{%- endcapture -%}
{%- if collectionKeywords contains searchThis -%}
{%- assign collectionCount = collectionCount | plus:1 -%}
{%- endif -%}
{%- endfor -%}

{% assign fakeCount = search.results_count | plus: collectionCount %}

Then change any instances of search.results_count on the page to fakeCount

 

Then add this bit where your search results are displayed:

{%- if collectionCount > 0 -%}
               <div class="grid__item>
              	<h2>Collections</h2>
                {% comment %}HACK FOR COLLECTION DISPLAY{% endcomment %}
                
                {% for collection in collections %}
                {% capture collectionKeywords %}{{ collection.title | lowercase }} {{ collection.description | handleize | replace: '-' ,' ' }}{% endcapture %}
                
                {% if collectionKeywords contains searchThis %}
                <a href="{{ collection.url }}">
                  
                          {% unless collection.image == blank %}
                            {% capture img_id %}ProductImage-{{ collection.image.id }}{% endcapture %}
                            {% capture wrapper_id %}ProductImageWrapper-{{ collection.image.id }}{% endcapture %}
                            {%- assign img_url = collection.image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
                            <div id="{{ wrapper_id }}" class="resp-img-wrapper js">
                              <div style="padding-top:{{ 1 | divided_by: collection.image.aspect_ratio | times: 100}}%;">
                                <img id="{{ img_id }}"
                                     class="resp-img lazyload"
                                     data-src="{{ img_url }}"
                                     data-widths="[180, 360, 470, 600, 750, 940, 1080, 1296, 1512, 1728, 2048]"
                                     data-aspectratio="{{ collection.image.aspect_ratio }}"
                                     data-sizes="auto"
                                     alt="{{ collection.image.alt | escape }}">
                               <img id="{{ img_id }}"
                                    class="resp-img-placeholder"
                                    src="{{ collection.image | img_url: '1x1' }}"
                                    width="{{ collection.image.width }}"
                                    height="{{ collection.image.height }}"
                                    alt="{{ collection.image.alt | escape }}">
                              </div>
                            </div>
                          {% endunless %}
                          <noscript>
                            <img src="{{ collection.image.src | img_url: 'large' }}" alt="{{ collection.image.alt | escape }}" class="product__img">
                          </noscript>
                        </div>

                        <p>{{ collection.title }}</p>

                      </div>
                    </a>
                {% endif %}
                {% endfor %}
              </div>
			  {%- endif -%}

it works well as long as you dont have a million collections to look through.

0 Likes