gpt4 book ai didi

html - 相关产品未正确显示

转载 作者:太空宇宙 更新时间:2023-11-04 09:00:04 24 4
gpt4 key购买 nike

我正在尝试在我的一个 shopify 商店中生成相关产品,它在某些产品上显示但大部分没有,我想要的是,首先通过匹配供应商/品牌显示相关产品,如果找不到则显示相同的产品类别:

有人可以建议如何处理这个吗?

<div class="related-products row">
{% assign vendor = product.vendor %}
{% assign vendor_handle = vendor | handleize %}

{% assign handle = product.handle %}
<h4 style="text-align:left;">More in this collection</h4>
{% assign counter = '' %}
{% for product in collections[vendor_handle].all_products %}
{% if vendor == product.vendor and counter.size < 4 and handle != product.handle %}
{% capture temp %}{{ counter }}*{% endcapture %}
{% assign counter = temp %}
<div class="col-md-3 col-sm-3 col-xs-12">
<div class="reveal">
<a href="{{ product.url | within: collection }}" title="{{ product.title }}">
<img src="{{ product.images.first | product_img_url: 'large' }}" class="img-responsive" alt="{{ product.title }}" />
</a>
</div>
<a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}">
{{ product.title | escape }}
</a>
</div>
{% endif %}
{% endfor %}
</div>

最佳答案

您正在使用以下行更改主要产品

{% for product in collections[vendor_handle].all_products %}

prod 是什么?

尝试以下操作

<div class="related-products row">
{% assign vendor = product.vendor %}
{% assign vendor_handle = vendor | handleize %}

{% assign handle = product.handle %}
<h4 style="text-align:left;">More in this collection</h4>
{% assign counter = 0 %}
{% for coll_product in collections[vendor_handle].all_products %}
{% if vendor == coll_product.vendor and counter < 4 and handle != coll_product.handle %}
{% assign counter = counter | plus: 1 %}
<div class="col-md-3 col-sm-3 col-xs-12">
<div class="reveal">
<a href="{{ coll_product.url | within: collection }}" title="{{ product.title }}">
<img src="{{ coll_product.images.first | product_img_url: 'large' }}" class="img-responsive" alt="{{ coll_product.title }}" />
</a>
</div>
<a href="{{ coll_product.url | within: collection }}" title="{{ coll_product.title | escape }}">
{{ coll_product.title | escape }}
</a>
</div>
{% endif %}
{% endfor %}
</div>

关于html - 相关产品未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42838016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com