2016-09-11 63 views
0

我正在使用shopify主題並試圖在主收集頁上輸出產品供應商信息。我曾嘗試將<p>{{ product.vendor | link_to_vendor }}</p>放置在我的主題的另一個區域工作的多個地方,但我沒有任何運氣 - 有人可以幫助解釋我可以如何完成此任務嗎?下面的代碼是我collection.liquid文件在收集頁面上顯示產品供應商

{% capture collectionDescription %} 
     {% if collection.description != blank and settings.collection-show-description %} 
     <div class="collection-description rte"> 
      {{ collection.description }} 
     </div> 
     {% endif %} 
    {% endcapture %} 


    {% if collection.image and settings.collection-show-featured-image %} 
     <div class="page-title collection-header-wrapper" style="background-image: url({{ collection.image.src | collection_img_url: '1024x1024' }});"> 
     <div class="collection-header"> 
      <h1>{{ collection.title }}</h1> 
      {{ collectionDescription }} 
     </div> 
     </div> 
    {% elsif collection.handle == 'all' %} 
     <h1 class="page-title">{{ 'collections.collection.all_products' | t }}</h1> 
     {{ collectionDescription }} 
    {% else %} 
     <h1 class="page-title">{{ collection.title }}</h1> 
     {{ collectionDescription }} 
    {% endif %} 

    {% assign productsPerPage = settings.collection-products-per-row | times: settings.collection-number-of-rows %} 
    {% paginate collection.products by productsPerPage %} 

    {% if collection.all_tags.size > 0 and settings.collection-enable-tag-filtering %} 
    <div class="collection-tag-selector"> 

     {% assign fallback = '' %} 
     {% if collection.handle %} 
     {% capture link %}/collections/{{ collection.handle }}{% endcapture %} 
     {% assign fallback = link %} 
     {% elsif collection.products.first.type == collection.title %} 
     {% capture link %}{{ collection.title | url_for_type }}{% endcapture %} 
     {% assign fallback = link %} 
     {% elsif collection.products.first.vendor == collection.title %} 
     {% capture link %}{{ collection.title | url_for_vendor }}{% endcapture %} 
     {% assign fallback = link %} 
     {% endif %} 

     <div class="select-wrapper"> 
     <div class="selected-text"> 
      {% if current_tags %} 
      {{ current_tags.first }} 
      {% else %} 
      {{ 'collections.collection.browse' | t }} 
      {% endif %} 
     </div> 
     <select data-fallback-url="{{ fallback }}"> 
      {% if current_tags %} 
      <option name="reset">-- {{ 'collections.collection.clear' | t }} --</option> 
      {% else %} 
      <option name="browse" selected disabled>{{ 'collections.collection.browse' | t }}</option> 
      {% endif %} 
      {% for tag in collection.all_tags %} 
      {% if current_tags contains tag %} 
       <option name="{{ tag | handle }}" selected>{{ tag }}</option> 
      {% else %} 
       <option name="{{ tag | handle }}">{{ tag }}</option> 
      {% endif %} 
      {% endfor %} 
     </select> 
     </div> 

    </div> 
    {% endif %} 

    <div class="collection-products products-per-row-{{settings.collection-products-per-row}}"> 
     {% for product in collection.products %} 
     {% include 'product-list-item' %} 
     {% else %} 
     <p class="empty">{{ 'collections.collection.no_products' | t }}</p> 
     {% endfor %} 

    </div> 


    {% if paginate.previous or paginate.next %} 
     {% include 'pagination' %} 
    {% endif %} 

    {% endpaginate %} 

enter image description here

回答

1

一個產品供應商。正如你所指出的,簡單的液體結構是product.vendor。因此,當您循環瀏覽集合中的所有產品時,您當然可以訪問它們。那麼你的實際問題是什麼?如果你想顯示供應商,最好的地方似乎在你的包含文件'product-list-item',因爲這是你的產品將被實例化的地方。

+0

所以我想要做的是這個;當用戶選擇一個集合時,我的主題顯示產品和價格,但不顯示供應商。我想輸出供應商並將其鏈接到供應商頁面。包含文件在哪裏?我還添加了一張圖片來顯示產品供應商未被顯示! – westman2222

+0

片段 - >產品列表項目 –

+0

感謝您的幫助! – westman2222

相關問題