问题
In Shopify how do I fetch names of custom collection that a particular product belongs to ?
Like for example to get SKU I can use {{ line_item.sku }}
or to get Price I can use {{ line_item.line_price
}}
回答1:
From the API docs, to list all custom collections for a certain product_id:
GET /admin/custom_collections.json?product_id=632910392
Response:
HTTP/1.1 200 OK
{
"custom_collections": [
{
"body_html": "<p>The best selling ipod ever</p>",
"handle": "ipods",
"id": 841564295,
"published_at": "2008-02-01T19:00:00-05:00",
"sort_order": "manual",
"template_suffix": null,
"title": "IPods",
"updated_at": "2008-02-01T19:00:00-05:00",
"image": {
"created_at": "2012-12-11T12:01:29-05:00",
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/collections/ipod_nano_8gb.jpg?0"
}
}
]
}
来源:https://stackoverflow.com/questions/14230720/getting-collection-names-of-products-in-shopify