Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How can i update product variants? Please help me.

How can i update product variants? Please help me.

Joy_Matubber
Shopify Partner
24 0 1

I have developed a shopify app. The app feature is to update the product variables using product update metafiled 
My demo code is bellow :

export const action = async ({ request }) => {
 
  const { admin, session } = await authenticate.admin(request);
  const prodiuctData = Object.fromEntries(await request.formData());

  const product = await admin.rest.resources.Product.find({
    session: session,
    id: prodiuctData.productID,
  });

  product.variants = [
    {
      id: parseInt(prodiuctData.variantValue),
      inventory_quantity: parseInt(prodiuctData.variantValue),
    },
  ];
 
  await product.save({
    update: true,
  });

  console.log(product);

  return json(null);
};

Can anyone please help me.
Replies 0 (0)