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

Reordering Product Option Values -> Various errors #263

Open
conorseed opened this issue Sep 7, 2022 · 0 comments
Open

Reordering Product Option Values -> Various errors #263

conorseed opened this issue Sep 7, 2022 · 0 comments

Comments

@conorseed
Copy link

Hey :) Looking at reordering the values of a specific product option named "Delivery Option". There's over 1000 products and most have this as an option field, and they all need reordering so that "Rural Delivery" is last.
Screen Shot 2022-09-07 at 4 16 51 PM

I can query the products and reorder the options just fine. However, I can't update the product. I've tried the below rest query:

$newProduct = array(
            "options" => $product['options']
    );
    $result = $shopify->Product($product['id'])->put($newProduct);

But this results in Request failed with HTTP Code 406.

I've also tried a graphql query to update as below:

$graphQL = <<<Query
    mutation updateProductOptions(\$input: ProductInput!) {
        productUpdate(input: \$input) {
            product {
              title, options{name, values}
            }
            userErrors {
              message
              field
            }
          }
      }
    Query;

    $variables = [
        "input" => [
            "id" => $product['id'],
            "options" => $product['options'],
        ]
    ];
    $result = $shopify->GraphQL->post($graphQL, null, null, $variables);

And this results in this error:
Variable $input of type ProductInput! was provided invalid value for options.0 (Could not coerce value "{\"name\"=>\"Delivery Option\", \"values\"=>[\"Ground Floor CBD\", \"Residential & Suburban Commercial\", \"Above Ground Floor Delivery\", \"Rural Delivery\"]}" to String), options.1 (Could not coerce value "{\"name\"=>\"Colours\", \"values\"=>[\"Black PU Leather - KG_SWT_PU\", \"Navy Fabric - KG_SWT_N_ASS\", \"Black Fabric - KG_SWT_B_ASS\"]}" to String)

Can anyone see what's going on here?

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

1 participant