Ad

How To Allow Customers To Sort By SKU In Shopify

- 1 answer

I'm trying to build in the ability for customers to sort product/collection pages by product SKU numbers. I'm not sure if this is something that can be done through Shopify's liquid code, though I thought I'd see if anyone could confirm that or knew of a possible alternate solution.

The sorting options are a common feature in Shopify and appear in most themes like this:

Shopify Sorting Options

The sorting code:

<select name="sortBy" id="sortBy">
  <option value="manual">{{ 'collections.sorting.featured' | t }}</option>
  <option value="best-selling">{{ 'collections.sorting.best_selling' | t }}</option>
  <option value="title-ascending">{{ 'collections.sorting.az' | t }}</option>
  <option value="title-descending">{{ 'collections.sorting.za' | t }}</option>
  <option value="price-ascending">{{ 'collections.sorting.price_ascending' | t }}</option>
  <option value="price-descending">{{ 'collections.sorting.price_descending' | t }}</option>
  <option value="created-descending">{{ 'collections.sorting.date_descending' | t }}</option>
  <option value="created-ascending">{{ 'collections.sorting.date_ascending' | t }}</option>
</select>
Ad

Answer

I think I can definitely answer to you that you cannot offer SKU search with Liquid and standard Shopify, hence no sorting either. SKU is not a first class citizen in Shopify, in the sense that it can be anything. A shop can have 10,000 products and all have the exact same SKU. It is hard to product search with the Shopify API based on SKU too. So it will be nearly impossible for you to offer a zippy real-time search/sort based on SKU unless you build that out yourself. You can index all your products by SKU in your own data server, and then with a Shopify App that embeds your server in your Shop, your customers' searches (& sorts) could be directed to your SKU lookups and that could work for you.

Search Shopify App store for a cheap and dirty search replacement and maybe that is all you need.

Ad
source: stackoverflow.com
Ad