Ad

Write Custom Search App In Shopify

- 1 answer

I need to implement our own custom product search in Shopify, but I have been unable to find out how exactly to do this.

I am not talking about the template which shows the search result, but we need to write custom code to decide exactly which products should be shown on the search page, and their order.

I can see there are a lot of apps out there which provides a custom search result/order so I guess it is possible to do, I was just unable to find any documentation about it.

I already have all the data needed to produce the desired search result, so my only problem is how to integrate with Shopify, so that Shopify send the search to our app, and then display the products our search app returns.

---- ADDED ----

What I would like in a perfect world, is that when the user does a search, Shopify should send the search phrase to our server. We would then generate an ordered list of product matches and return that list to shopify. Shopify would then present the products to the user, exactly as if the products were found by shopify using the internal shopify search engine.

But it seems like i might have misunderstood how that google search thing worked, and it seems like what I want is simply not possible.

Ad

Answer

To customize the search result in your shopify store you have to manipulate the search result provided by the search result. To do so you have to find in your theme where logic for search operation is written.

Mostly you will find it in search.liquid file. You need to filter the search result there. Suppose you want to restrict products of particular vendor in the search result then you can do it as follow.

{% for item in search.results %}
    {% if item.vendor != 'Reebok' %}
      {% include 'search-result' %}         
    {% endif %}
{% endfor %}

Here search-result will be the snippet responsible represent each search result in the search list. Simillarly you have to manipilate the search result pagination too.

Ad
source: stackoverflow.com
Ad