2017-03-16 13 views
0

私はshopifyストアで関連製品を生成しようとしていますが、製品にはほとんど表示されていません。同じカテゴリの製品を表示してください:関連する製品が正しく表示されない

誰にもこれをどう対処するかお勧めしますか?

<div class="related-products row"> 
{% assign vendor = product.vendor %} 
{% assign vendor_handle = vendor | handleize %} 

{% assign handle = product.handle %} 
<h4 style="text-align:left;">More in this collection</h4> 
{% assign counter = '' %} 
{% for product in collections[vendor_handle].all_products %} 
    {% if vendor == product.vendor and counter.size < 4 and handle != product.handle %} 
    {% capture temp %}{{ counter }}*{% endcapture %} 
    {% assign counter = temp %} 
    <div class="col-md-3 col-sm-3 col-xs-12"> 
    <div class="reveal"> 
     <a href="{{ product.url | within: collection }}" title="{{ product.title }}"> 
     <img src="{{ product.images.first | product_img_url: 'large' }}" class="img-responsive" alt="{{ product.title }}" /> 
     </a> 
    </div> 
    <a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}"> 
     {{ product.title | escape }} 
    </a> 
    </div> 
    {% endif %} 
{% endfor %} 
</div> 

答えて

1

あなたは次の行

{% for product in collections[vendor_handle].all_products %}

prodは何を使って、メインの製品を変更していますか?

<div class="related-products row"> 
{% assign vendor = product.vendor %} 
{% assign vendor_handle = vendor | handleize %} 

{% assign handle = product.handle %} 
<h4 style="text-align:left;">More in this collection</h4> 
{% assign counter = 0 %} 
{% for coll_product in collections[vendor_handle].all_products %} 
    {% if vendor == coll_product.vendor and counter < 4 and handle != coll_product.handle %} 
    {% assign counter = counter | plus: 1 %} 
    <div class="col-md-3 col-sm-3 col-xs-12"> 
    <div class="reveal"> 
     <a href="{{ coll_product.url | within: collection }}" title="{{ product.title }}"> 
     <img src="{{ coll_product.images.first | product_img_url: 'large' }}" class="img-responsive" alt="{{ coll_product.title }}" /> 
     </a> 
    </div> 
    <a href="{{ coll_product.url | within: collection }}" title="{{ coll_product.title | escape }}"> 
     {{ coll_product.title | escape }} 
    </a> 
    </div> 
    {% endif %} 
{% endfor %} 
</div> 
次のことを試してみてください
関連する問題