Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metafield on Product post #323

Open
Lollichkeit opened this issue May 28, 2024 · 3 comments
Open

Metafield on Product post #323

Lollichkeit opened this issue May 28, 2024 · 3 comments

Comments

@Lollichkeit
Copy link

Lollichkeit commented May 28, 2024

My Code:

...
$metafield = [
        'namespace' => "custom",
        'key' => "message",
        'value' => $message,
        'owner_resource' => "product",
        'owner_id' => $product_id,
        'value_type' => 'single_line_text_field',
];

$metafields = shopify->Product($product_id)->Metafield->post($metafield);
...

My Error:
Fatal error: Uncaught PHPShopify\Exception\ApiException: Not Found in /.../phpclassic/php-shopify/lib/ShopifyResource.php:540 Stack trace: #0 /home/svsqauxl/vendor/phpclassic/php-shopify/lib/ShopifyResource.php(419): PHPShopify\ShopifyResource->processResponse(Array, 'metafield') #1 /... .php(213): PHPShopify\ShopifyResource->post(Array) #2 /... .php(126): PHPProduct->updateMetaProducte() #3 {main} thrown in /.../phpclassic/php-shopify/lib/ShopifyResource.php on line 540

Please help me to upload the metadata.

@rossvor
Copy link

rossvor commented Jun 14, 2024

The type of error you are getting (Not Found) suggests that likely $product_id does not match any product on the store, so double check that you using the correct value there.

Also, provided metafield fields don't look right.
Should be something like this:

$metafield = [
        'namespace' => "custom",
        'key' => "message",
        'value' => $message,
        'type' => 'single_line_text_field',
];

Check the Shopify reference here

@ankesh4040
Copy link

ankesh4040 commented Sep 10, 2024

@rossvor @Lollichkeit Did it helped ? I am getting error Request failed with HTTP Code 400

@ankesh4040
Copy link

$metafieldv = 
     [     
    'namespace' => "custom",
    'key' => "features",
    'value' => "API updated",
    'type' => 'single_line_text_field'
     ]
;

$metafields = $shopify->Product('7713539269680')->Metafield->post($metafieldv);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants