如何让客户在 Shopify 中按 SKU 排序

How to allow customers to sort by SKU in Shopify

我正在尝试构建让客户能够按产品 SKU 编号对 product/collection 页面进行排序的功能。我不确定这是否可以通过 Shopify 的流动代码来完成,但我想我会看看是否有人可以确认或知道可能的替代解决方案。

排序选项是 Shopify 中的一项常见功能,并且出现在大多数模版中,如下所示:

排序代码:

<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>

我想我可以肯定地回答你,你不能用 Liquid 和标准的 Shopify 提供 SKU 搜索,因此也没有排序。 SKU 不是 Shopify 中的第一个 class 公民,因为它可以是任何东西。一家商店可以有 10,000 种产品,并且所有产品都具有完全相同的 SKU。 Shopify API 也很难根据 SKU 进行产品搜索。因此,除非您自己构建它,否则您几乎不可能提供基于 SKU 的快速实时 search/sort。您可以在您自己的数据服务器中按 SKU 为所有产品编制索引,然后使用将您的服务器嵌入您的商店的 Shopify 应用程序,您的客户的搜索(和排序)可以定向到您的 SKU 查找,这可能对您有用。

在 Shopify 应用商店中搜索廉价且肮脏的搜索替代品,也许这就是您所需要的。