Ruby 是否可以在shopify商店中动态设置“特色”收藏?

Ruby 是否可以在shopify商店中动态设置“特色”收藏?,ruby,shopify,liquid,Ruby,Shopify,Liquid,我希望能够在shopify商店的特色产品部分展示两个不同的系列。我希望这样做是为了避免显示与正在查看的产品相同的特色产品。我看到在“自定义主题”页面上可以选择要显示的集合,但此集合无法更改。我认为最好的方法是使用产品标签,然后根据标签更改特色系列。但是我没有成功。非常感谢您的帮助 {% for tag in product.tags %} {% if tag contains 'top' %} {% assign settings.home_featured_prod

我希望能够在shopify商店的特色产品部分展示两个不同的系列。我希望这样做是为了避免显示与正在查看的产品相同的特色产品。我看到在“自定义主题”页面上可以选择要显示的集合,但此集合无法更改。我认为最好的方法是使用产品标签,然后根据标签更改特色系列。但是我没有成功。非常感谢您的帮助

{% for tag in product.tags %}

    {% if tag contains 'top' %}

        {% assign settings.home_featured_products == 'Home' %}

    {% elsif tag contains 'bottom' %}

        {% assign settings.home_featured_products == 'Frontpage' %}

    {% endif %}

{% endfor %}
产品页面上还包含一个featured-products.liquid文件,用于控制featured products部分的布局。可以创建其中两个显示两个不同集合的文件,然后根据标记显示不同的文件。但是,我不确定如何控制此文件中显示的集合

<!-- snippets/featured-products.liquid -->

{% if section_number > 1 and number_of_index_sections > 1 %}
 <hr class="hr--medium hr--clear">
{% endif %}

<div class="section-header text-center">
  <h1>{{ 'home_page.sections.featured_products' | t }}</h1>
  <hr class="hr--small">
</div>

<div class="{% if settings.collection_products_grid == 'collage' %}grid grid-collage{% else %}grid-uniform{% endif %}">

  {% comment %}
    Loop through products in your Frontpage collection.
    This collection is created by default, but you must add products to it.

    See the snippet 'snippets/product-grid-collage.liquid'.

    `is_reverse_row_product`, `three_row_index_product`, `collection_product_count_product`, and `divisible_by_three_product` are
    all used by 'snippets/product-grid-collage.liquid'
  {% endcomment %}
  <div class="grid-uniform__aligner">
  {% if settings.home_featured_products == blank or collections[settings.home_featured_products].empty? or collections[settings.home_featured_products].products_count == 0 %}

    {% comment %}
      For onboarding new users to your theme, we add some default products and onboarding tutorials to help populate their store
    {% endcomment %}
    {% unless emptyState %}
      {{ 'theme-onboarding.css' | global_asset_url | stylesheet_tag }}
      {% assign emptyState = true %}
    {% endunless %}

    {% include 'onboarding-featured-products' %}

  {% else %}

    {% if settings.collection_products_grid == 'collage' %}

      {% assign is_reverse_row__product = false %}
      {% assign three_row_index__product = 0 %}
      {% if collections[settings.home_featured_products].products_count > 50 %}
        {% assign collection_product_count__product = 50 %}
      {% else %}
        {% assign collection_product_count__product = collections[settings.home_featured_products].products_count %}
      {% endif %}
      {% assign divisible_by_three__product = collection_product_count__product | modulo:3 %}

      {% for product in collections[settings.home_featured_products].products %}
        {% include 'product-grid-collage' %}
      {% endfor %}

    {% else %}

      {% assign grid_item_width = 'medium--one-half large--one-third' %}
      {% for product in collections[settings.home_featured_products].products %}
        {% include 'product-grid-item' %}
      {% endfor %}

    {% endif %}

  {% endif %}
  </div>
</div>

如果您不想在集合中显示当前产品,只需执行以下操作:

{% assign handle = product.handle %}
{% for product in collection[featured_products].products %}
  {% unless product.handle == handle %}
    Your product goes here.
  {% endunless %}
{% endfor %}

您可以用指定的任何产品对象替换“您的产品在此处运行”。我不确定是否100%符合您的要求。您不希望在特色部分显示与当前产品相同的产品,对吗?那么,如果您可以检查当前产品手柄是否与特色产品手柄相同并跳过该手柄,那么为什么要使用2个集合。。。为什么要为此使用2个集合?请详细说明。我同意滴水:@drip我认为这是避免在推荐部分显示相同产品的最简单方法。我同意你的解决方案是有道理的。那我该怎么做呢?比较两个产品句柄并使用液体代码从集合中删除一个产品。请参阅@ButsAndCats answer。下面是我可能替换您的产品的示例。您可能有一个包含{%include'产品网格项'%}的产品网格,或者您可以使用{{{product.title}}@SpencerM进行测试。我认为这将帮助你:非常有用的链接,将让你知道如果解决方案的工作时,我有机会尝试它今晚晚些时候。再次感谢你的帮助,我真的很感激。您将能够使用“您的产品在此处使用”区域中的备忘单中的任何产品对象