Hello everyone.
What am I trying to accomplish?
I am trying to create ten products by running BulkOperationRunMutation on productCreate mutation.
Here is test data from my jsonl file for better context:
START TEST DATA
{“input”:{“title”:“/000011”,“descriptionHtml”:“A machine screw is generally a smaller fastener (less than 1/4 inches (6.35 mm) in diameter) threaded the entire length of its shank that usually has a recessed drive type (slotted, Phillips, etc.). Machine screws are also made with socket heads (see above), in which case they may be referred to as socket head machine screws.”,“productType”:“044”}}
{“input”:{“title”:“/012324”,“descriptionHtml”:“012324 BOLT”,“productType”:“000”}}
{“input”:{“title”:“/012339”,“descriptionHtml”:“012339”,“productType”:“000”}}
{“input”:{“title”:“/N-B05201987”,“descriptionHtml”:“1 1/4 IN PLATED STEEL DRYWALL SCREWS”,“productType”:“000”}}
{“input”:{“title”:“0001111”,“descriptionHtml”:“A machine screw is generally a smaller fastener (less than 1/4 inches (6.35 mm) in diameter) threaded the entire length of its shank that usually has a recessed drive type (slotted, Phillips, etc.). Machine screws are also made with socket heads (see above), in which case they may be referred to as socket head machine screws.”,“productType”:“044”}}
{“input”:{“title”:“00022-2416-401”,“descriptionHtml”:“1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,“productType”:“006”}}
{“input”:{“title”:“00022-2416-401”,“descriptionHtml”:“1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,“productType”:“3188”}}
{“input”:{“title”:“00022-2417-401”,“descriptionHtml”:“1/4-20 HEX NUT ZINC”,“productType”:“010”}}
{“input”:{“title”:“00022-2418-401”,“descriptionHtml”:“BASE PLATE (1/4-20)”,“productType”:“3141”}}
{“input”:{“title”:“00022-3460-401”,“descriptionHtml”:“7/8-9 X 6 TAP BOLT ZB”,“productType”:“000”}}
END TEST DATA
As you can see two products have the same title (00022-2416-401), with different productTypes. I already understand that productCreate has an input field called: handle, which creates a unique string of the product’s title when the product is created.
I also understand that you can have multiple products with the same title and the handles will be different.
Here is a graphql example below of how that is done with the return data:
mutation productCreate($input: ProductCreateInput!) {
productCreate(product: $input) {
product {
id
title
descriptionHtml
handle
}
userErrors {
message
field
}
}
}
input is the same for both responses:
{
“input”: {
“title”:“00022-2416-401”,
“descriptionHtml”: “1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,
“productType”: “006”
}
}
Response 1 :
“data”: {
“productCreate”: {
“product”: {
“id”: “gid://shopify/Product/9589293777176”,
“title”: “00022-2416-401”,
“descriptionHtml”: “1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,
“handle”: “00022-2416-401”
},
“userErrors”:
}
}
Response 2 :
“data”: {
“productCreate”: {
“product”: {
“id”: “gid://shopify/Product/9589295284504”,
“title”: “00022-2416-401”,
“descriptionHtml”: “1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,
“handle”: “00022-2416-402”
},
“userErrors”:
}
}
As you can see the handles are different for both responses using the same inputs. NOW here is core issue: In the bulkOperation status payload url, the data clearly states a userError: “userErrors”:[{“message”:“Handle has already been taken”,“field”:[“handle”]}]}},“__lineNumber”:6} when I run the bulkOperationRunMutation on productCreate.
**For absolute clarity **
Here is the return payload data from shopify after the bulkOperation has been completed
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262156056”,“title”:“/000011”,“descriptionHtml”:“A machine screw is generally a smaller fastener (less than 1/4 inches (6.35 mm) in diameter) threaded the entire length of its shank that usually has a recessed drive type (slotted, Phillips, etc.). Machine screws are also made with socket heads (see above), in which case they may be referred to as socket head machine screws.”,“handle”:“000011”},“userErrors”:}},“__lineNumber”:0}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262385432”,“title”:“00022-2416-401”,“descriptionHtml”:“1/4-20 X 1 HEX CAP SCREW ASSEMBLED”,“handle”:“00022-2416-401”},“userErrors”:}},“__lineNumber”:5}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262254360”,“title”:“/012324”,“descriptionHtml”:“012324 BOLT”,“handle”:“012324”},“userErrors”:}},“__lineNumber”:1}
{“data”:{“productCreate”:{“product”:null,“userErrors”:[{“message”:“Handle has already been taken”,“field”:[“handle”]}]}},“__lineNumber”:6}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262090520”,“title”:“/012339”,“descriptionHtml”:“012339”,“handle”:“012339”},“userErrors”:}},“__lineNumber”:2}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262287128”,“title”:“00022-2417-401”,“descriptionHtml”:“1/4-20 HEX NUT ZINC”,“handle”:“00022-2417-401”},“userErrors”:}},“__lineNumber”:7}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262221592”,“title”:“/N-B05201987”,“descriptionHtml”:“1 1/4 IN PLATED STEEL DRYWALL SCREWS”,“handle”:“n-b05201987”},“userErrors”:}},“__lineNumber”:3}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262352664”,“title”:“00022-2418-401”,“descriptionHtml”:“BASE PLATE (1/4-20)”,“handle”:“00022-2418-401”},“userErrors”:}},“__lineNumber”:8}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262123288”,“title”:“0001111”,“descriptionHtml”:“A machine screw is generally a smaller fastener (less than 1/4 inches (6.35 mm) in diameter) threaded the entire length of its shank that usually has a recessed drive type (slotted, Phillips, etc.). Machine screws are also made with socket heads (see above), in which case they may be referred to as socket head machine screws.”,“handle”:“0001111”},“userErrors”:}},“__lineNumber”:4}
{“data”:{“productCreate”:{“product”:{“id”:“gid://shopify/Product/9589262319896”,“title”:“00022-3460-401”,“descriptionHtml”:“7/8-9 X 6 TAP BOLT ZB”,“handle”:“00022-3460-401”},“userErrors”:}},“__lineNumber”:9}
?What Gives?
As you can see shopify is skipping over one of the products stating that the handles are the same. Is this a legitimate bug? Or is this intentional? Either way my solution would be to collect all products that fire a userErrors to then manually loop through each product doing a simple graphql call just to productCreate to overcome this issue. Can you guys help me out with a solution?
Thank You.