2015-09-01 173 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> 

我希望产品能帮助您