How to setup Smart navigation through Shopify collections

Modified on: Fri, Dec 1, 2017 at 4:46 PM


Note: Smart navigation through Shopify collections is available only for the $18 subscribers.


In the Searchanise Admin Panel on the Navigation page, you’ll need to enable one of these options:


1. Navigation through redirecting Shopify collections links


In this case Searchanise will replace all links to collections ([store_url]/collections/...) in your store to the links that lead to the page with the Searchanise search results widget ([store_url]/pages/search-results-page?collection=...). Now clicking on the collection link will show products in the Searchanise search results widget.


In order to hide the “Search Results” page title when viewing products in the collections, in the templates/page.liquid page templates, you’ll need to add the snize-search-results-page-title css class to the element that contains the page title. Take a look at the example:


<h1 class="snize-search-results-page-title">{{ page.title }}</h1>


Important: The links are replaced using the javascript code that starts executing only after the page is loaded, we recommend that you accelerate loading of Searchanise scripts using this guide.



In this case links will not be replaced, but you’ll need to modify store templates to make the Searchanise search results widget replace the code that displays products.


In order to do that, please do the following:

1. Go to Online Store - Themes section of the admin panel of your store and click Actions - Edit code.


2. Click Snippets - Add a new snippet.

3. Insert searchanise-navigation.liquid into the input field and click Create snippet. This way you’ll create a new snippet with the searchanise-navigation.liquid name.



4. Copy and paste the following code to the created snippet.


<script src="//www.searchanise.com/widgets/shopify/init.js?a=[API Key]"></script>
<div class="snize" id="snize_results"></div>

<style type="text/css"><!--
/* Themes hack */
div.grid div.grid-item.large--two-thirds.push--large--one-sixth {
    left: 0;
    width: 100%;
}

/* Load spinner */
#snize-preload-spinner {
    height: 100px;
    width: 32px;
    margin: 0 auto;
    background-position: 0px center;
    background-repeat: no-repeat;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYAAAAALCAYAAAB2x1oQAAAACXBIWXMAAAsTAAALEwEAmpwYAAAIj0lEQVR42u2bbWhTWRrHn3Puzc37JNYmTduhTMZBZLBF6gt+2h1HMxRUOrjmgzJfXGUXLU23Y0WHYpdWikp13LZU2cVZvwwK1i0WEcq2ju5+ErVSapEi40TqtE3TtE2meb0v5+wHE4l3kjRX9qaF6QMXwsn/3t/93//Jc9P0XID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NDQ0NEyoya+srDxtNptH5HyGYYjD4Wjs6emZWEn+9Xr9YYxxIIM+oNfrVc/farUeYll2Xq5nWXbearUeUspXOv9LS0sPcRwXlPM5jguWlpaqzlfi3+Vy/azVausRQmIG/SOLxdKqlK8k/4aGhgmLxdKAMSZyvU6ne1pRUdGqZv/p6emZcDgcjQzD/IpvNptHKisrT6vJX27/+eSfeg7AJAjCXyilbnizDnU0j3WozQDwWXLoAcuy7XmsQ6+CN+ugezUazd9sNlsYAODevXumxcXFE5Ik7UMIFVFKRzmOO793794HheBfvnzZNDk5eZLn+f0YYyuldNRkMp1f4jmA/xu/sbHxgxcvXrzzHMDatWs7ent7/70S/Q8MDHwciUSaIW0dstFobK+pqfmpEPl3dHR8EggEmuHddfDtTU1NP74PX+n8P3z48PpXr141A8AXKX7yOYAXheAr9Z9cB34yuQ58nmGYPrPZ3LFz58734ivNP7kO/iRCqIoQEuQ47lZ5efn5Y8eOhQvRf9xu9xdzc3Mn0p8DWL9+/dlLly79Ugj+cvtfKv/VWq3VWq3V+g3W/wAZmNaB1vZW4QAAAABJRU5ErkJggg==);
}
--></style>

<script>// <![CDATA[
(function(window, undefined) {
    var sXpos = 0, sIndex = 0, sTotalFrames = 12, sInterval = null;

    if (document.getElementById('snize_results').innerHTML != '') {
        return;
    }

    document.getElementById('snize_results').innerHTML = '<div id="snize-preload-spinner"></div>';
    sInterval = setInterval(function()
    {
        var spinner = document.getElementById('snize-preload-spinner');
        if (spinner) {
            document.getElementById('snize-preload-spinner').style.backgroundPosition = (- sXpos) + 'px center';
        } else {
            clearInterval(sInterval);
        }

        sXpos  += 32;
        sIndex += 1;

        if (sIndex >= 12) {
            sXpos  = 0;
            sIndex = 0;
        }
    }, 30);

    if (window.location.href.indexOf('collection=') != -1) {
        var elements = document.getElementsByClassName('snize-search-results-page-title');
        for (var i = 0; i < elements.length; i++) {
            elements[i].style.display = 'none';
        }
    }
}(window));
// ]]></script>


5. Replace [API Key] in the first line of the code with your current API Key



You can find the API key at Smart Search & Instant Search app → Dashboard tab.



Please do not forget to click Save. 


6. Then you’ll need to change the collection.liquid template. To do it go to Templates - collection.liquid and replace the Shopify code that shows collections with the following code:


{% include 'searchanise-navigation' %}


Please do not forget to click Save.

7. Go to Smart Search & Instant Search app → Smart Navigation page. Choose Navigating through embedding HTML code into the Shopify template. Please don’t forget to save the settings by clicking Apply Changes!
 P. S. We recommend backing up the files before changing them. If you disable the “Navigating through embedding HTML code into the Shopify template” option or delete the Searchanise application, you’ll have to insert the code you removed back where it was.


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.