You connect a fulfillment tool or inventory tracker to your Shopify store and it complains that some variants have no SKU. This often happens after a migration, with products created by hand, or with supplier feeds that leave the field empty.
You can fill the gaps with a CSV file or with a script. Both change live products, so start with the rules below.
1. Read this before you import a CSV
Shopify's import rules can remove data if the file is wrong:
- Blank cells overwrite. If a non-required column is in your file and a cell is blank, the value in your store becomes blank.
- Missing columns are left alone. If a non-required column is not in your file at all, that value stays as it is.
- SKU needs the option columns. If the file has SKU but not Option1 name and Option1 value, Shopify deletes the product variant option.
- Do not edit option values. Changing Option1 value deletes the existing variant IDs and creates new ones, which can break other apps.
- You cannot cancel it. Once an import starts, it runs to the end.
So the plan is: keep an untouched copy of the export, upload as few columns as possible, and test on one product first.
2. Export your products
- In your Shopify admin, go to Products and click Export.
- Choose All products.
- Choose the CSV format for Excel, Numbers, or another spreadsheet program.
- Click Export products. Shopify may send the file by email.
Save one copy of this file and do not touch it. That is your record of the old values.
3. Keep only the columns you need
Work on a second copy. Keep these columns and delete the rest:
- URL handle and Title
- Option1 name and Option1 value, plus the Option2 and Option3 name and value columns if your products use them
- SKU
These are the header names in Shopify's current CSV format. An older export may say Handle and Variant SKU. Leave the headers exactly as Shopify exported them.
Some rows only hold an extra product image. They have a handle but no Option1 value. They are not variants and do not need a SKU. Because you removed the image columns, delete those rows too. Keep every variant row, including variants that already have a SKU.
4. Fill the blank SKUs
Add a filter and show only rows where SKU is blank and Option1 value is not. In the first visible SKU cell, build an identifier from a prefix, the month and the row number:
="TSHIRT-2611-" & TEXT(ROW(), "0000")
In row 45 this gives TSHIRT-2611-0045. The 2611 part (November 2026) matters: row numbers repeat in your next export, so without it a later run could create the same SKU for a different product.
Fill the formula down the visible rows, clear the filter, then copy the SKU column and paste it back as values only.
Now check for duplicates. If SKU is in column G, put this in a spare column, fill it down and look for TRUE:
=AND(G2<>"", COUNTIF(G:G, G2)>1)
Delete the spare column when you are done. Save the file as CSV with UTF-8 encoding.
5. Import one product first
- Make a small file with the header row and all the variant rows of one product.
- Go to Products, click Import and add the file.
- Select Overwrite products with matching handles. Without it, Shopify ignores products that already exist.
- Click Upload and continue, read the summary, then click Import products.
- Open that product and check its variants, options, prices, images and inventory.
If everything is right, import the full file. The size limit is 15 MB, so split it if you need to.
6. Use the Admin API instead
If a supplier feed keeps adding products without SKUs, a script saves you from repeating this. It sends only the SKU field of each variant.
Two things changed if you follow an older guide. The productVariantUpdate mutation is not in API version 2026-10: use productVariantsBulkUpdate, where the SKU sits inside inventoryItem. And you can no longer create new custom apps in the Shopify admin. You create the app in the Dev Dashboard, give it the read_products and write_products scopes, install it on your store, and exchange its client ID and secret for a token that lasts 24 hours. This client credentials grant works when the app and the store belong to the same Shopify organization.
Set SHOPIFY_SHOP (your myshopify.com subdomain), SHOPIFY_CLIENT_ID and SHOPIFY_CLIENT_SECRET as environment variables, then save this as fill_skus.py:
import os
import sys
from collections import defaultdict
import requests
SHOP = os.environ["SHOPIFY_SHOP"]
BASE = f"https://{SHOP}.myshopify.com/admin"
PREFIX = "AUTO"
APPLY = "--apply" in sys.argv
VARIANTS = """
query Variants($after: String) {
productVariants(first: 250, after: $after) {
nodes { id sku title product { id title } }
pageInfo { hasNextPage endCursor }
}
}
"""
UPDATE = """
mutation FillSkus($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkUpdate(productId: $productId, variants: $variants) {
productVariants { id sku }
userErrors { field message }
}
}
"""
def get_token():
r = requests.post(
f"{BASE}/oauth/access_token",
data={
"grant_type": "client_credentials",
"client_id": os.environ["SHOPIFY_CLIENT_ID"],
"client_secret": os.environ["SHOPIFY_CLIENT_SECRET"],
},
timeout=30,
)
r.raise_for_status()
return r.json()["access_token"]
TOKEN = get_token()
def graphql(query, variables):
r = requests.post(
f"{BASE}/api/2026-10/graphql.json",
headers={"X-Shopify-Access-Token": TOKEN},
json={"query": query, "variables": variables},
timeout=60,
)
r.raise_for_status()
body = r.json()
if body.get("errors"):
raise RuntimeError(body["errors"])
return body["data"]
missing = defaultdict(list)
used = set()
after = None
while True:
page = graphql(VARIANTS, {"after": after})["productVariants"]
for v in page["nodes"]:
sku = (v["sku"] or "").strip()
if sku:
used.add(sku)
else:
missing[v["product"]["id"]].append(v)
if not page["pageInfo"]["hasNextPage"]:
break
after = page["pageInfo"]["endCursor"]
for product_id, variants in missing.items():
updates = []
for v in variants:
sku = f"{PREFIX}-{v['id'].rsplit('/', 1)[-1]}"
if sku in used:
raise RuntimeError(f"{sku} is already in use")
print(v["product"]["title"], "/", v["title"], "->", sku)
updates.append({"id": v["id"], "inventoryItem": {"sku": sku}})
if not APPLY:
continue
for i in range(0, len(updates), 250):
data = graphql(UPDATE, {"productId": product_id, "variants": updates[i:i + 250]})
errors = data["productVariantsBulkUpdate"]["userErrors"]
if errors:
raise RuntimeError(errors)
total = sum(len(v) for v in missing.values())
print(f"{total} variants without a SKU.", "Updated." if APPLY else "Dry run, nothing changed.")
Run python fill_skus.py first. It only prints what it would do. When the list looks right, run python fill_skus.py --apply.
The script builds each SKU from the variant's own ID, so two variants never get the same one. It stops at the first error, including when Shopify limits the request rate. Run it again and it picks up the variants that are still empty. I checked the two queries against Shopify's 2026-10 schema and ran the script against a mock API, not a live store, so try it on a development store first.
Still stuck?
If products arrive faster than you can clean them up and you need a script that catches bad product data automatically, this is the kind of fix I do.
FAQ
How do I find products without SKUs in Shopify?
Export your products to a CSV file and filter for rows where SKU is blank and Option1 value is not. Rows without an Option1 value can be extra images, which do not need a SKU.
Will importing a CSV delete my product data?
It can. With overwrite on, blank cells in non-required columns erase the value in your store, and a file with SKU but without the Option1 columns deletes the variant option. Upload only the columns you need and test on one product first.
Can I generate SKUs automatically in Excel?
Yes. Join a prefix, the month and the ROW() function, paste the result as values, and check for duplicates with COUNTIF before you import.
Why does productVariantUpdate not work anymore?
It is not part of Shopify Admin API version 2026-10. Use productVariantsBulkUpdate and set the SKU inside inventoryItem.
Originally published at watershowdigital.com/blog/shopify-bulk-update-missing-skus. Need a hand with your app or automation? WaterShow Digital fixes and builds it, fixed quote first.
Top comments (0)