What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

put metafiled Multi

put metafiled Multi

SCoccia
Tourist
6 1 4

Hi is possible to update multi metafiled? I have a product with 5 metafiled is possibile update all togheter?

 I try with php

 

$data = array('metafield' => 
    array(
            'namespace' => 'custom',
            'key' => 'Genere',
            'value' => 'Uomo',
            'type' => 'single_line_text_field'
        ),          
        array(
        'namespace' => 'custom',
        'key' => 'style',
        'value' => 'Sport',
        'type' => 'single_line_text_field'              
    )
  );

 

 
but the read only the first... 

 

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 525

Hi @SCoccia 👋

 

If your app has permissions to modify all 5 metafields on the product, you can use the `productUpdate` mutation to update them using their `metafield.id`:

 

mutation ($input: ProductInput!) {
    productUpdate(input: $input) {
        product {
            id
            metafields (first: 5, namespace:"foobar"){
                nodes {
                    id
                    key
                    value
                }
            }
        }
    }
}

 

{
    "input": {
        "id":"gid://shopify/Product/123",
        "metafields": [
            {
                "id": "gid://shopify/Metafield/456",
                "value": "cat"
            },
            {
                "id": "gid://shopify/Metafield/789",
                "value": "dog"
            }           
        ]
    }
}

 

Hope that helps!

@Umiko 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

SCoccia
Tourist
6 1 4

Hi thank you but Is a php page with curl not use node js...