将特定集合加载为Shpoify相关产品

时间:2017-05-26 21:22:01

标签: shopify liquid

我想在最终用户查看我的某个产品页面时加载产品附件。我已经想出如何从显示中排除集合, 但我不确定如何设置液体'专门打电话给一个集合。

{% assign number_of_related_products_to_show = 12 %}

{% assign number_of_related_products_to_fetch = number_of_related_products_to_show | plus: 1 %}
{% assign exclusions = 'frontpage,all,dual_camera,single_camera,series_dr650s,series_dr400_series' | split: ',' %}

    {% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
        {% assign found_a_collection = false %}
        {% for c in product.collections %}
            {% if collection and collection.all_products_count > 1 %}
                {% unless exclusions contains collection.handle %}
                    {% assign found_a_collection = true %}
                    {% assign collection = c %}
                {% endunless %}
            {% endif %}
        {% endfor %}
    {% endif %}

{% if collection and collection.products_count > 1 %}
<div class="h_row_4 animated  fadeInUp" data-animation="fadeInUp">
  <div class="clearfix">
    <h3>{{ 'products.general.related_products' | t }}</h3>
    {% assign current_product = product %}
    {% assign current_product_found = false %}
  </div>
  <div class="carosel product_c">
    <div class="row"> 
      <div id="featured-products-section-{{ section.id }}" class="owl-carousel">
        {% for product in collection.products limit: number_of_related_products_to_fetch %}
        {% if product.handle == current_product.handle %}
        {% assign current_product_found = true %}
        {% else %}
        {% unless current_product_found == false and forloop.last %}
        {% include 'product-loop' %}
        {% endunless %}
        {% endif %}
        {% endfor %}
      </div>
    </div>
  </div>
</div>
{% endif %}

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

循环访问特定集合: {%for collections in collections [handle-of-the-collection-you-want] .products%} 做一点事 {%endfor%}