【问题标题】:Shopify: Display products from a collection on homepage using liquidShopify:使用液体在主页上显示集合中的产品
【发布时间】:2015-09-01 19:54:20
【问题描述】:

我正在尝试将我客户的 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>

简单,但没用。刚拿到一个空盒子,里面什么都没有。有人知道在我的收藏中显示项目的正确代码吗?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    试试这个代码,它将调用名为 Most Popular 的集合中的产品

    <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>
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多