Shopify: Unable to create Product options using GraphQL API

Shopify: Unable to create Product options using GraphQL API

Jayram
Shopify Partner
1 0 0

Hi Shopify experts,

 

I'm trying to create options and variants for product using GraphQL API.

Always I'm getting 

LINKED_METAFIELD_DEFINITION_NOT_FOUND

 error.

 

Creating Products:

While Creating the product, I'm sending following info in variables:

"metafields"=> [
[
"namespace"=> "products-meta",
"key"=> "product-title",
"type"=> "single_line_text_field",
],
[
"namespace"=> "products-meta",
"key"=> "product-finish",
"type"=> "single_line_text_field",
],
[
"namespace"=> "products-meta",
"key"=> "product-shade",
"type"=> "single_line_text_field",
],
]
 
Creating Options:
And while creating the options:
$variables = [
"productId" => $product->shopifyproductid,
"options" => [
[
"name"=>"Finish",
"linkedMetafield"=>[
"namespace"=>"products-meta",
"key"=>"product-finish",
'values'=>['Brushed Nickel', 'Olde Bronze', ]
],
],
],
];
 
While creating the options, I'm getting LINKED_METAFIELD_DEFINITION_NOT_FOUND error.
Not sure  whats wrong I'm doing here. Your help will be appreciated.
 
Thanks,
Jay
Reply 1 (1)

Eric-HAN
Shopify Partner
187 25 20

Hi there

Before creating your product with product options, have you checked the definitions of your metafields by using GraphQL queries to determine if they exist?

query {
  metafieldDefinitions(first: 250, ownerType: PRODUCT) {
    edges {
      node {
        name
        namespace
        key
        type {
          name
        }
      }
    }
  }
}

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee