如何使用shopify通过单个请求获取特定集合的所有产品标签?
您好,我正在使用shopify中的storefront api开发ios应用程序,现在我需要获取特定集合的所有产品标签,但在我找不到的文档中,是否有人可以建议我这是否可行?请尝试以下方法: 第1步: 创建用于搜索标记的模板,如:如何使用shopify通过单个请求获取特定集合的所有产品标签?,shopify,Shopify,您好,我正在使用shopify中的storefront api开发ios应用程序,现在我需要获取特定集合的所有产品标签,但在我找不到的文档中,是否有人可以建议我这是否可行?请尝试以下方法: 第1步: 创建用于搜索标记的模板,如: {% layout none %} {% capture output %} {% for collection in collections %} {% if forloop.index == 1 %}""{% endif %} {%
{% 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: ']' }}
第二步:
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" ) )
资料来源:
如果仍然没有帮助,请告诉我。请尝试以下方法: 第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: ']' }}
第二步:
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" ) )
资料来源:
如果仍然没有帮助,请告诉我