简体   繁体   English

如何使用shopify一次请求获取所有产品标签以进行规范收集?

[英]How to get all product tags for specifi collection with single request using shopify?

嗨,我正在shopify中使用店面api开发ios应用,现在我需要获取特定集合的所有产品标签,但是在文档中我找不到,有人可以建议我这样做吗?

Please try with this way: 请尝试这种方式:

Step 1: create the template for searching tags like: 步骤1:创建用于搜索标签的模板,例如:

{% layout none %}
{% capture output %}
{% for collection in collections %} 
        {% if forloop.index == 1 %}""{% endif %}
        {% if collection.all_tags.size > 0 %}
            {% for tag in collection.all_tags %}

                {% if output contains tag %}
                {% else %}
                    ,"{{tag}}"
                {% endif %}

            {% endfor %}  
        {% endif %}     
   {% endfor %}
{% endcapture %}
{{ output | strip_newlines | prepend: '[' | append: ']' }}

Step 2: PHP Sample Code 步骤2: PHP示例代码

function pullJson( $url ) {
     $curl = curl_init();
     curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => $url,
        CURLOPT_USERAGENT => 'agent-sark'
    ));

    $resp = curl_exec($curl);
    curl_close($curl);
  return json_decode( $resp, true );
  }
 $storeUrl = "http://". { your store } .".myshopify.com";
 /* this will gets you all the tags ( of course with duplicate ) */
 $pTags = array_unique( pullJson( $storeUrl ."/search?view=tags" ) )

source : here 来源: 这里

if it's still not help, please let me know. 如果仍然没有帮助,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM