# Shopify Variant Reconciliation: catalog migration audit (`asunoki/shopify-variant-reconciliation`) Actor

Read-only audit of two Shopify product CSVs (before and after a migration, or last week's and this week's re-import): missing, duplicate and mismatched variants by SKU and barcode, with review files. Optional approval list flags changes nobody approved. Never writes to your store.

- **URL**: https://apify.com/asunoki/shopify-variant-reconciliation.md
- **Developed by:** [Seisuke Nagahara](https://apify.com/asunoki) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 variant checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Shopify Variant Reconciliation — catalog migration audit

Compare your Shopify product CSV **before and after a migration** (or a big re-import), variant by variant, and get a list of what to fix. **Read-only**: it never connects to your store, needs no Shopify credentials and changes nothing.

### What it finds

- Variants that exist before but not after — and variants that only exist after
- SKU missing or changed; barcode missing or different
- Duplicate SKUs and duplicate barcodes
- Option values that changed (for example Size "S" became "Small")
- Price and compare-at price differences (a blank price is not treated as 0)
- Cases it cannot decide — they go to a review list instead of being guessed

### Who it is for

Shopify agencies and freelancers who move stores, in-house e-commerce teams after a replatforming, and anyone who keeps SKUs and barcodes in sync with an ERP or inventory system.

### How to use it

1. Export the product CSV **before** the migration (old store, or your old platform's export in Shopify CSV format).
2. Export the product CSV from the **new** Shopify store (Products › Export).
3. Give both files to the Actor as links or paste the text, then press Start.

The input form is pre-filled with a tiny 9-variant demo, so you can press Start once to see the output before using your own files.

#### Input

| Field | What to enter |
|---|---|
| Before-migration CSV (URL or paste) | The old catalog |
| After-migration CSV (URL or paste) | The new Shopify catalog |
| Max variants per file | Default 50,000 (up to 100,000). The run stops with an error above this size, before any variant is charged |
| Include clean matches in the dataset | Off by default (the dataset lists only rows that need attention) |

- Current Shopify column names (`URL handle`, `SKU`, `Barcodes`, `Option1 value`, `Price`) and the older ones (`Handle`, `Variant SKU`, `Variant Barcode`, `Option1 Value`, `Variant Price`) are both accepted.
- Each file can be up to 50 MB. UTF-8, with or without BOM.
- A file needs a `URL handle` (or `Handle`) column and at least a SKU or a barcode column.

#### Memory and run time

The default is **1 GB memory and a 300-second timeout**, which fits catalogs up to about 50,000 variants. For 50,000–100,000 variants, raise "Max variants per file" and choose **2 GB** in the run options (the start fee is charged per GB, so 2 GB adds $0.00005). The maximum is 4 GB. In our local tests, 10,000 variants took 1–4 seconds and 100,000 variants took 7–38 seconds, depending on how many rows had problems. Runs above 50,000 variants have not yet been measured on Apify, so start with a smaller file if you can.

### Weekly re-import check (optional)

If you re-import products every week (ERP, supplier feed, bulk edits), use **last week's approved export as the before file** and **this week's export as the after file**, and give an **approval list**. The Actor separates the changes you approved from the changes nobody approved.

Approval CSV:

| key | change | new_value | note |
|---|---|---|---|
| LT-NAT-S | price | 3500 | autumn sale |
| 4901234567894 | barcode | | new supplier code |
| LT-NAT-XL | add | | new size |

- `key`: SKU or barcode. `change`: price, compare_at, sku, barcode, options, handle, add, remove. `new_value` is optional; `(blank)` means the field is now empty.
- A change counts as approved only when key, change type and (if given) the new value match. Lines that are invalid, conflict with each other or match more than one variant are listed and **never used**.

Extra files: `weekly_unapproved_changes.csv`, `weekly_approved_changes.csv`, `weekly_approved_not_applied.csv` (approved but not in this week's export), `weekly_invalid_approvals.csv`. The price is the same as a normal run. Without an approval list the report is exactly as before.

### Output

Files in the run's key-value store:

| File | Contents |
|---|---|
| `summary.json` | Counts by status and issue |
| `reconciliation.csv` | Every variant, before and after side by side |
| `missing_variants.csv` | Variants missing on either side |
| `duplicate_keys.csv` | SKUs or barcodes used by more than one variant |
| `review_required.csv` | Rows a person should check |
| `suggested_actions.csv` | One suggested action per problem row |

The dataset contains the rows that need attention.

Example rows (from the demo data):

| status | issues | suggested action |
|---|---|---|
| missing_after | variant_missing_after_migration | Recreate this variant in the new catalog (or confirm it was intentionally dropped). |
| matched_with_differences | option_mismatch | Check the option values; changing them in Shopify creates new variant IDs. |
| matched_with_differences | barcode_missing_after | Copy the barcode to the new variant. |

### How matching works

- **SKU**: surrounding spaces are removed and the comparison is exact. A SKU that differs only in letter case is matched but flagged for review.
- **Barcode**: the current `Barcodes` column may hold several values separated by `;`, each with a type such as `gtin:` or `upc:`; the type is removed before comparing, so `gtin:4901234567900` equals a legacy `4901234567900`. Spaces and hyphens are removed. 8/12/13/14-digit codes with a valid GS1 check digit are compared as GTIN-14, so a UPC-A and the same code written as an EAN-13 with a leading zero match. Barcodes with a wrong check digit are compared as typed and flagged.
- If a SKU or barcode points to more than one variant, the row goes to review. Nothing is resolved automatically.
- Results do not depend on row order.

### Important

The suggested actions are for a person to review. **They are not a Shopify import file.** Importing a wrongly structured CSV into Shopify can delete and recreate variants.

### Pricing

Pay per event:

- **$2.50 per 1,000 before-migration variants compared** ($0.0025 per variant), charged once per run after the report is saved.
- A small Apify start fee of $0.00005 per run (per GB of memory).
- Platform usage is included.

Examples: the 9-variant demo costs about $0.02; 1,000 variants cost $2.50; 4,000 variants cost $10.00.

If your "Maximum cost per run" is too low for the file, the run stops **before** comparing anything and no variants are charged. A run that fails on invalid input is not charged for variants.

### Your data

The files are read during the run. The results are stored only in your own Apify account's storage, and nothing is sent to Shopify or to any third party. Product catalogs do not need customer data, so do not upload files that contain customer personal data. You can delete the run's storage when you are done.

### Not supported yet

- Connecting to the Shopify Admin API
- Comparing inventory across locations
- Non-Shopify CSV layouts
- XML feeds

### If a run fails

Open the `ERROR` record in the key-value store:

| code | meaning |
|---|---|
| `input_missing` | Give a URL or paste the text for both files |
| `download_failed` | The link could not be downloaded |
| `csv_missing_columns` | Not a Shopify product CSV (no handle column, or no SKU or barcode column) |
| `csv_conflicting_columns` | The file has both "Barcode" and "Barcodes" columns |
| `csv_empty` / `csv_unclosed_quote` / `csv_duplicate_column` | The file is empty or not valid CSV |
| `limit_exceeded` | The file is larger than 50 MB, or has more variants than "Max variants per file" |
| `spending_limit` | Raise your maximum cost per run, or split the file |

### FAQ

- **Why "review required"?** The Actor does not guess when a SKU or barcode matches several variants.
- **Does it fix my store?** No. It tells you what to fix.
- **How fast is it?** The 9-variant demo finished in about 3 seconds on Apify. Local timings for larger files are listed under "Memory and run time". Large runs have not yet been measured on the platform.
- **Is it proven?** It is new. There are no reviews yet.

***

Shopify is a trademark of Shopify Inc. This Actor is an independent tool and is not affiliated with, sponsored by or endorsed by Shopify.

# Actor input Schema

## `beforeUrl` (type: `string`):

Link to the product CSV exported before the migration (old store or old platform in Shopify CSV format). Use a link only you control; the file is read once.

## `beforeText` (type: `string`):

Or paste the CSV text instead of a URL.

## `afterUrl` (type: `string`):

Link to the product CSV exported from the new Shopify store.

## `afterText` (type: `string`):

Or paste the CSV text.

## `maxVariants` (type: `integer`):

Stop with an error above this size (protects your spending limit). Default 50,000. Up to 100,000 is accepted; above 50,000 choose 2 GB memory (large runs are not yet measured on Apify).

## `includeMatchedRows` (type: `boolean`):

By default the dataset lists only rows that need attention; the full table is always in reconciliation.csv.

## `weeklyCheck` (type: `boolean`):

Turn on to produce the weekly files even without approvals (then every change is listed as not approved).

## `approvalsUrl` (type: `string`):

Columns: key (SKU or barcode), change (price, compare_at, sku, barcode, options, handle, add, remove), new_value (optional; (blank) means now empty), note (optional).

## `approvalsText` (type: `string`):

Or paste the approval CSV, for example:
key,change,new_value,note
LT-NAT-S,price,3500,autumn sale

## Actor input object example

```json
{
  "beforeText": "Handle,Title,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Variant SKU,Variant Barcode,Variant Price\nlinen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800\nlinen-tee,,,Natural,,M,LT-NAT-M,4901234567900,3800\nlinen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3800\nlinen-tee,,,Navy,,S,LT-NAV-S,4901234567924,3800\nlinen-tee,,,Navy,,M,LT-NAV-M,4901234567931,3800\ncanvas-tote,Canvas Tote,Size,Regular,,,CT-REG,0012345678905,2400\ncanvas-tote,,,Large,,,CT-LRG,4901234567948,2900\nsocks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200\nsocks,,,25-27cm,,,WS-2527,4901234567955,1200\n",
  "afterText": "URL handle,Title,Option1 name,Option1 value,Option2 name,Option2 value,SKU,Barcodes,Price\nlinen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800\nlinen-tee,,,Natural,,M,LT-NAT-M,,3800\nlinen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3500\nlinen-tee,,,Navy,,Small,LT-NAV-S,4901234567924,3800\ncanvas-tote,Canvas Tote,Size,Regular,,,CT-REG,012345678905,2400\ncanvas-tote,,,Large,,,CT-LARGE,4901234567948,2900\nsocks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200\nsocks,,,25-27cm,,,WS-2527,4901234567962,1200\ngift-box,Gift Box,Title,Default Title,,,GB-01,,500\n",
  "maxVariants": 50000,
  "includeMatchedRows": false,
  "weeklyCheck": false
}
```

# Actor output Schema

## `issues` (type: `string`):

Dataset: one row per problem variant.

## `summary` (type: `string`):

summary.json: counts by status and issue.

## `reconciliation` (type: `string`):

reconciliation.csv: every variant, before and after.

## `missingVariants` (type: `string`):

missing_variants.csv

## `duplicateKeys` (type: `string`):

duplicate_keys.csv

## `reviewRequired` (type: `string`):

review_required.csv

## `suggestedActions` (type: `string`):

suggested_actions.csv

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "beforeText": `Handle,Title,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Variant SKU,Variant Barcode,Variant Price
linen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800
linen-tee,,,Natural,,M,LT-NAT-M,4901234567900,3800
linen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3800
linen-tee,,,Navy,,S,LT-NAV-S,4901234567924,3800
linen-tee,,,Navy,,M,LT-NAV-M,4901234567931,3800
canvas-tote,Canvas Tote,Size,Regular,,,CT-REG,0012345678905,2400
canvas-tote,,,Large,,,CT-LRG,4901234567948,2900
socks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200
socks,,,25-27cm,,,WS-2527,4901234567955,1200`,
    "afterText": `URL handle,Title,Option1 name,Option1 value,Option2 name,Option2 value,SKU,Barcodes,Price
linen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800
linen-tee,,,Natural,,M,LT-NAT-M,,3800
linen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3500
linen-tee,,,Navy,,Small,LT-NAV-S,4901234567924,3800
canvas-tote,Canvas Tote,Size,Regular,,,CT-REG,012345678905,2400
canvas-tote,,,Large,,,CT-LARGE,4901234567948,2900
socks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200
socks,,,25-27cm,,,WS-2527,4901234567962,1200
gift-box,Gift Box,Title,Default Title,,,GB-01,,500`
};

// Run the Actor and wait for it to finish
const run = await client.actor("asunoki/shopify-variant-reconciliation").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "beforeText": """Handle,Title,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Variant SKU,Variant Barcode,Variant Price
linen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800
linen-tee,,,Natural,,M,LT-NAT-M,4901234567900,3800
linen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3800
linen-tee,,,Navy,,S,LT-NAV-S,4901234567924,3800
linen-tee,,,Navy,,M,LT-NAV-M,4901234567931,3800
canvas-tote,Canvas Tote,Size,Regular,,,CT-REG,0012345678905,2400
canvas-tote,,,Large,,,CT-LRG,4901234567948,2900
socks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200
socks,,,25-27cm,,,WS-2527,4901234567955,1200
""",
    "afterText": """URL handle,Title,Option1 name,Option1 value,Option2 name,Option2 value,SKU,Barcodes,Price
linen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800
linen-tee,,,Natural,,M,LT-NAT-M,,3800
linen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3500
linen-tee,,,Navy,,Small,LT-NAV-S,4901234567924,3800
canvas-tote,Canvas Tote,Size,Regular,,,CT-REG,012345678905,2400
canvas-tote,,,Large,,,CT-LARGE,4901234567948,2900
socks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200
socks,,,25-27cm,,,WS-2527,4901234567962,1200
gift-box,Gift Box,Title,Default Title,,,GB-01,,500
""",
}

# Run the Actor and wait for it to finish
run = client.actor("asunoki/shopify-variant-reconciliation").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "beforeText": "Handle,Title,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Variant SKU,Variant Barcode,Variant Price\\nlinen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800\\nlinen-tee,,,Natural,,M,LT-NAT-M,4901234567900,3800\\nlinen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3800\\nlinen-tee,,,Navy,,S,LT-NAV-S,4901234567924,3800\\nlinen-tee,,,Navy,,M,LT-NAV-M,4901234567931,3800\\ncanvas-tote,Canvas Tote,Size,Regular,,,CT-REG,0012345678905,2400\\ncanvas-tote,,,Large,,,CT-LRG,4901234567948,2900\\nsocks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200\\nsocks,,,25-27cm,,,WS-2527,4901234567955,1200\\n",
  "afterText": "URL handle,Title,Option1 name,Option1 value,Option2 name,Option2 value,SKU,Barcodes,Price\\nlinen-tee,Linen Tee,Color,Natural,Size,S,LT-NAT-S,4901234567894,3800\\nlinen-tee,,,Natural,,M,LT-NAT-M,,3800\\nlinen-tee,,,Natural,,L,LT-NAT-L,4901234567917,3500\\nlinen-tee,,,Navy,,Small,LT-NAV-S,4901234567924,3800\\ncanvas-tote,Canvas Tote,Size,Regular,,,CT-REG,012345678905,2400\\ncanvas-tote,,,Large,,,CT-LARGE,4901234567948,2900\\nsocks,Wool Socks,Size,23-25cm,,,WS-2325,4901234567955,1200\\nsocks,,,25-27cm,,,WS-2527,4901234567962,1200\\ngift-box,Gift Box,Title,Default Title,,,GB-01,,500\\n"
}' |
apify call asunoki/shopify-variant-reconciliation --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,asunoki/shopify-variant-reconciliation"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/QWxXOQI1rGczzh0QW/builds/Ch7XCv5VH0sBCF4if/openapi.json
