Admin API: how to avoid create duplicate product

Admin API: how to avoid create duplicate product

cloudymum
Visitor
3 0 0

Could anyone answer me?

Is there any way to avoid create duplicate product?

E.g. custom_collection, if post with exsited "handle", it will return 422 error.

Replies 4 (4)

productsync
Shopify Partner
740 38 161

Hi

You may need to provide some more information. If you are getting the error than I'm assuming you are not able to create a duplicate product already. Or do you mean you want to see this error to avoid using same handle? The handle is always unique so cannot be duplicated across different products.

Regards

Tom

cloudymum
Visitor
3 0 0

It will generate a new "handle" with suffix like '-1', '-2', ... when call product post with a exsited "handle".

I just want to know is there any field when i call product post with an exsited, then it would return error.

Ysi
Shopify Partner
1 0 0

I face same troubles, and I tried to set id when id of some handle exists like below, so as to update nothing. However, products are duplicated...

I would like for Shopify team to deal with  this problem.
===

"query": "mutation productCreate($input: ProductInput!,  $media: [CreateMediaInput!]) { productCreate(input: $input,  media: $media) { product { id } } }",
    "variables": {
        "input": {
            "id": "gid://shopify/Product/xxxx",
            ...
}
GrantDB
Shopify Partner
80 3 14

Don't suppose anyone found a solution to this did they?  When doing a create fail if the handle already exists.  Just some flag in the payload would be enough.

 

Thanks

Grant