【问题标题】:Sort Shopify Products by Multiple Filters按多个过滤器对 Shopify 产品进行排序
【发布时间】:2015-02-12 17:05:38
【问题描述】:

我正在尝试通过多个过滤器对一组产品进行排序。我想按标签(collection.products | sort: 'tags')和标题升序(collection.products | sort: 'title')对我的产品进行排序。我尝试了以下多种变体:

{% assign sortedProducts = collection.products | sort: 'title' | sort: 'tags' %}
{% assign sortedProducts = collection.products | sort: 'tags' | sort: 'title' %}
{% assign sortedProducts = collection.products | sort: 'title' %}
{% assign sortedProducts = sortedProducts | sort: 'tags' %}
{% assign sortedProducts = collection.products | sort: 'tags' %}
{% assign sortedProducts = sortedProducts | sort: 'title' %}

它们都不起作用。我看到的问题的答案涉及按标签过滤然后按字母顺序排序,但我希望在同一页面上按标签和标题排序。如果不可能,那么我会在排序前进一步研究按标签过滤。

谢谢!

【问题讨论】:

    标签: sorting shopify


    【解决方案1】:

    显然,对于液体标签,您不应该留下空格,如下所示(未经测试):

    {% assign sortedProducts = collection.products|sort:'title'|sort:'tags' %}
    {% assign sortedProducts = collection.products|sort:'tags'|sort:'title' %}
    {% assign sortedProducts = collection.products|sort:'title' %}
    {% assign sortedProducts = sortedProducts|sort:'tags' %}
    {% assign sortedProducts = collection.products|sort:'tags' %}
    {% assign sortedProducts = sortedProducts|sort:'title' %}
    

    还有一个更复杂的问题:分页。 您的设置或主题设置中的某处有分页设置。默认值为每个“页面”50 个产品。根据我的经验,问题是当你要求它排序时,它可能只在前 50 个产品中排序:(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 2016-08-15
      相关资源
      最近更新 更多