2017-09-28 1 views
1

가 나는 제품 개체가? 바람직하게는 id.Liquid를 사용하여 Shopify 컬렉션에서 제품을 확인하는 방법은 무엇입니까? 나는이 객체 내에서 특정 제품을 확인할 수 있습니다 방법</p> <p><code>assign rel_products = collection.products</code></p> <p>:

{% if rel_products contains related_product.id %} 
    {% continue %} 
{% endif %} 

위의이 코드는 작동하지 않습니다 : 그래서 내가 for 루프에서 할 수 continue이 검사를하고 있어요.

답변

0

액체에 익숙하지 않지만 rel_products 변수에 코드를 할당하는 것처럼 보이므로 루프를 반복하고 각 반복마다 ID를 확인해야합니다. 아마 이것과 같은 것?

{% for product in rel_products %} 
    {% if product contains 'Id you want to check' %} 
     {% continue %} 
    {% endif %} 
{% endfor %} 
0

나는 이것이 당신이 필요로하는 해결책이라고 생각합니다.

{% assign rel_products = collection.products %} 

{% for product in rel_products %} 
     {% if product.id == 12345789 %} //123456789 is just an example 
      <!-- Something you want to do --> 
     {% endif %} 
{% endfor %} 
관련 문제