将一个集合拉到Shopify上的自定义页面,但除了图像之外没有显示任何信息

时间:2016-05-17 22:55:47

标签: collections shopify liquid product

我正在寻找解决问题的方法。我正在尝试使用Shopify将产品集合移至.liquid中的唯一页面。我已设法拉出正确的集合并将其显示在行中,但没有显示额外信息,如价格或标题或详细信息。这是我用来将集合拉到我的页面上的代码。有什么建议吗?

任何信息都会有所帮助!我也有问题集中在我的页面上。

{% assign collection = collections.aaron-wallis %}
  {% assign products = collections.aaron-wallis.products %}
    {% capture new_row %}
<div class="product_row">
    {% endcapture %}
    {% for product in products limit: limit %}
       <a href="{{ product.url | within: collection }}" title="{{ product.featured_image.alt | escape }}">
           <img {% if settings.align_height %} 
               style="height:{{ settings.collection_height }}px"
                {% endif %} 
               src="{{ product.featured_image|product_img_url: 'large' }}" 
               alt="{{ product.featured_image.alt | escape }}" />
       </a> 
    {% endfor %}
</div>

2 个答案:

答案 0 :(得分:0)

您可以使用以下方法遍历特定的收藏品:

{% for product in collections[yourcollectionhandle].products %}
  {{ product.title }}
{% endfor %}

答案 1 :(得分:0)

没有显示任何信息,因为您编写的代码不应显示图像以外的任何信息。

查看代码的这一部分。

 {% for product in products limit: limit %}
       <a href="{{ product.url | within: collection }}" title="{{ product.featured_image.alt | escape }}">
           <img {% if settings.align_height %} 
               style="height:{{ settings.collection_height }}px"
                {% endif %} 
               src="{{ product.featured_image|product_img_url: 'large' }}" 
               alt="{{ product.featured_image.alt | escape }}" />
       </a> 
    {% endfor %}

它应该只显示链接的产品图像。如果您想要更多产品名称,价格

{% for product in products limit: limit %}
       <a href="{{ product.url | within: collection }}" title="{{ product.featured_image.alt | escape }}">
           <img {% if settings.align_height %} 
               style="height:{{ settings.collection_height }}px"
                {% endif %} 
               src="{{ product.featured_image|product_img_url: 'large' }}" 
               alt="{{ product.featured_image.alt | escape }}" />
           <p class="product-title">{{ product.title }}</p>
           <p class="product-price">{{ product.price }}</p>
       </a> 
    {% endfor %}