You connect a new fulfillment tool or inventory tracker to your Shopify store and it immediately throws errors. Some orders fail to sync, or stock levels stay stuck at zero even after you receive a new shipment.
The system flags that your variants are missing SKUs. This happens when you migrate from another platform, use a dropshipping integration, or create products manually.
A SKU is the reliable way for external software to identify which physical item needs to be picked off a shelf. Product titles and handle names change, but SKUs remain static. You can fix missing identifiers manually with a spreadsheet or write a script to automate the backfilling process.
1. Finding empty SKUs via CSV export
Shopify lets you pull your catalog, modify specific columns, and push updates back to your live store.
Open your Shopify admin and navigate to Products.
Click Export.
Select the option to export all products and choose the CSV format.
Open the downloaded file in Microsoft Excel or Google Sheets.
Look for the column titled Variant SKU. This column holds the identifier for every variant. If a product has no variants, the default version gets its own row and needs a SKU.
Set a filter on the Variant SKU column to only show blank cells. This hides the products that are already set up correctly so you do not overwrite them.
2. Generating new SKUs systematically
Generating SKUs with a formula prevents typos. A standard format combines a brand prefix, a category code, and a unique number.
In the first empty cell of the SKU column, write a spreadsheet formula to generate an identifier based on the current row number:
="BRAND-TSHIRT-" & TEXT(ROW(), "0000")
This formula takes a text prefix and attaches the row number, padded with leading zeros. If you put this in row 45, the result is BRAND-TSHIRT-0045.
Copy this formula and paste it down the entire column for all filtered blank rows. Once the cells are filled, convert the formulas to plain text by highlighting the cells, copying them, and pasting them as values over the exact same cells.
Save your spreadsheet as a CSV file. Go back to the Products page in Shopify and click Import. Upload your saved file. Check the box to Overwrite any current products that have the same handle. This updates your existing database instead of creating duplicate items.
3. Automating backfills with the GraphQL API
Spreadsheets work well for a one-time cleanup. If your store imports new items from external supplier feeds that drop SKUs, you will repeat the CSV process every week.
You can build an automation to handle this in the background. A script can run on a daily schedule, ask the Shopify GraphQL API for variants with empty SKUs, and update them.
Create a custom app in your project settings to get an access token. The script uses that token to query the Admin API.
Here is a Python example that finds variants missing a SKU:
import requests
SHOPIFY_DOMAIN = "your-store.myshopify.com"
ACCESS_TOKEN = "shpat_your_access_token_here"
headers = {
"X-Shopify-Access-Token": ACCESS_TOKEN,
"Content-Type": "application/json"
}
query = """
{
products(first: 50, query: "sku:''") {
edges {
node {
id
title
variants(first: 10) {
edges {
node {
id
sku
title
}
}
}
}
}
}
}
"""
response = requests.post(
f"https://{SHOPIFY_DOMAIN}/admin/api/2024-01/graphql.json",
headers=headers,
json={"query": query}
)
print(response.json())
This query asks for products where a variant has an empty SKU. The script receives a JSON response containing the internal IDs for those variants.
Once you have the IDs, the script can generate a new SKU string using your custom logic. It then sends a mutation request back to the Shopify API to update the variant:
mutation = """
mutation productVariantUpdate($input: ProductVariantInput!) {
productVariantUpdate(input: $input) {
productVariant {
id
sku
}
userErrors {
field
message
}
}
}
"""
variables = {
"input": {
"id": "gid://shopify/ProductVariant/1234567890",
"sku": "AUTO-GEN-1001"
}
}
update_response = requests.post(
f"https://{SHOPIFY_DOMAIN}/admin/api/2024-01/graphql.json",
headers=headers,
json={"query": mutation, "variables": variables}
)
Running a script like this on a cron job ensures that no product stays in your store without a valid SKU.
Still stuck?
If products get imported so fast that weekly manual cleanups are too slow, and you need a script built to catch and update bad product data automatically, this is the kind of fix I do.
FAQ
How do I find products without SKUs in Shopify?
Export your product catalog to a CSV file from the Shopify admin. Once opened in a spreadsheet, filter the SKU column to only show blank cells. This isolates the variants that need to be updated.
Can I generate SKUs automatically in Excel?
Yes, you can write a formula using text prefixes and the row number. An example is joining the text "BRAND-" with the ROW() function to create a unique identifier for each empty cell.
How do I stop suppliers from importing products without SKUs?
You cannot always control external feeds, but you can automate the cleanup. A custom script using the Shopify GraphQL API can periodically scan for empty SKUs and update them based on your rules.
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)