2016-09-11 2 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

관련 문제