Reputation: 39
I am working on shopify private app . During some task adding some meta fields using shopify api method:
PUT /admin/custom_collections/#{id}.json
{
"custom_collection": {
"id": 841564295,
"metafields": [
{
"key": "new",
"value": "newvalue",
"value_type": "string",
"namespace": "global"
}
]
}
}
========================================== next i need to get all collection meta fields but i did't found any solution.
Upvotes: 0
Views: 1705
Reputation: 11427
Any resource in Shopify provides a method to get the Metafield resources attached to them. So given that you have a collection ID, think along these lines:
/custom_collections/:id/metafields.json
...to get the Metafields resources using RestAPI. Beware the fact that you might only get 50 of the resources since that is an internal limit. You can get more when you page through the resources and provide a limit. With paging, you can get all the resources, up to 250 Metafields per call.
Note that there are other ways to do this too, using mutations with the GraphQL library for example.
Upvotes: 1