Put metafiled Multi

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…

2 Likes

Hi @SCoccia :waving_hand:

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

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

1 Like