Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello
Hope you all are well!!!
I have been stuck in 1 point. I want to create multiple metafields at one API call. but not working... can somebody please help me.
Hello, this is possible in our GraphQL API. For example, with the `productUpdate` mutation you can input multiple metafields. See https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/productupdate?#product...for the product example.
To learn more visit the Shopify Help Center or the Community Blog.
Hello @swalkinshaw
Hope you are well!! I'm using REST admin api for product metafield. I want to post this both metafields vlalue using REST admin api .
My code:
$array1 = array (
'product' =>
array (
'metafields' =>
array (
0 =>
array (
'namespace' => 'your_namespace',
'key' => 'your_key',
'value' => 'your_value',
'value_type' => 'string',
),
1 =>
array (
'namespace' => 'your_namespace_2',
'key' => 'your_key_2',
'value' => 'your_value',
'value_type' => 'string',
),
),
),
);
$getmetafields = shopify_call($token, $shop, "/admin/api/2021-04/products/6406423871657/metafields.json", $array1, 'POST');
$getmetafields = json_decode($getmetafields['response'], JSON_PRETTY_PRINT);
echo "<pre>";
print_r($getmetafields);
echo "</pre>";
Hi,
This is my question too.
Is there any way to add necessary meta fields to one level above the products?
I mean adding meta fields somehow that could be assigned automatically to every new product, It's not reasonable to send a separate request for every single field, imaging all of my 1000 products have 50 fields, so how it will be handled?
Really I need to make 50000 requests?
Or I'm totally wrong here?
Did you have any answer related to this?
I am also interested in creating different metafields in one single call if possible.
We released a new and improved metafieldsSet mutation in our GraphQL Admin API: https://shopify.dev/api/admin-graphql/2021-10/mutations/metafieldsSet as part of the 2021-10 API version.
It lets you create or update multiple (up to 25) metafields on _different_ owners as well.
To learn more visit the Shopify Help Center or the Community Blog.
Hello, It's not possible to update multiple metafields in a single API call. To achieve that you will need to make a separate API call for each metafield.