2015-09-01 81 views
0

我試圖在我家客戶的Shopify商店中添加最受歡迎的產品。我聽說你要做的就是創建一個集合(我打電話給我的最流行的),然後使用下面的代碼,以顯示產品:Shopify:使用液體在主頁上顯示產品集合

<div class="product span4"> 
    {% assign best = collections["most-popular"] %} 
     <ul> 
      {% for product in best limit:10 %} 
       <li><a href="{{ product.url }}">{{ product.title }}</a></li> 
      {% endfor %} 
     </ul> 
    </div> 

簡單,但沒有奏效。剛剛拿到一個沒有任何東西的空白盒子。任何人都知道在我的收藏中顯示物品的正確代碼?

回答

0

剛剛嘗試這個代碼,它會調用從集合命名最受歡迎

<div class="product-sec"> 


<ul> 

{% for product in collections.most_popular.products limit: 4 %} <!--/*********** most_popular is name under collections limit is uded to show no. of products ******/ --> 
      <li><a href="{{ product.url}}"><img style="width:177px;height:177px;" src="{{ product.featured_image | product_img_url: 'medium' }}" alt=""></a></li> 
    {% endfor %} 
    </ul> 
    <span><a href="{{ shop.url }}/collections/most-popular">Most Popular</a></span> 

我希望產品能幫助您