Shopify ERP Sync Reverting Prices or Writing compareAtPrice: "0"? Last-Writer-Wins Forensics
The ticket usually reads like this: "We marked 40 products down on Friday. Monday morning they're back at full price, and our Sale collection now contains 600 items that aren't on sale." Nobody touched the store over the weekend. Something did — and it was not a person.
This guide walks through a real, public bug in Microsoft's own Shopify connector that produced exactly this kind of damage, explains why multi-writer setups make it inevitable, and gives you a forensic procedure plus a circuit breaker you can drop into a webhook handler.
1. Primary source: Business Central connector, PR #8125
The Dynamics 365 Business Central Shopify connector is open source in microsoft/BCApps. Pull request
#8125, titled
"[Shopify] Fix bulk variant price update sending compareAtPrice as "0"", is the releases/27.5 backport of the original fix in
#7949 (merged to main on 2026-05-11; the backport merged on 2026-05-22).
According to the PR description, the bug lived only in the bulk path: when a single price sync touched 100 or more records, the
connector switched to productVariantsBulkUpdate through Shopify's bulk operations API and built JSONL from a fixed template. Two defects followed:
- Clearing. When Compare at Price was set to 0 in BC, the single-variant GraphQL path correctly sent
compareAtPrice: null, but the bulk JSONL hard-codedCompareAtPrice := '0'. - Defaulting. When Compare at Price had not changed but Price or Unit Cost had, the bulk path defaulted to
Format(ShopifyVariant."Compare at Price", 0, 9)— which is"0"for every variant without a sale. That silently overwrote any compare-at price a merchant had set in Shopify admin, on every sync.
The essential change, abridged from the diff:
// ShpfyBulkUpdateProductPrice.GetInput (before)
'{ "productId": "gid://shopify/Product/%1", "variants": [{ "id": "gid://shopify/ProductVariant/%2",
"price": "%3", "compareAtPrice": "%4" }]}'
// after: %4 carries the whole optional fragment, or nothing at all
'{ "productId": "gid://shopify/Product/%1", "variants": [{ "id": "gid://shopify/ProductVariant/%2",
"price": "%3"%4 }]}'
// ShpfyVariantAPI.UpdateProductPrice (after)
// valid sale (Price < Compare at Price) -> , "compareAtPrice": "<value>"
// compare-at changed and is <= Price -> , "compareAtPrice": null
// compare-at unchanged in BC -> (omitted; Shopify keeps its value)
Two lessons generalize far beyond Business Central. First, "0" is not "empty": Shopify stores it as a real 0.00 compare-at
price, which the PR notes can surface as a "was" price on some themes and corrupts feeds and analytics. Second, a writer that sends fields it did
not change will eventually overwrite someone else's work. The fix is not just "send null" — it is "omit what you don't own."
2. Anatomy of a Last-Writer-Wins conflict
Shopify has no concept of field ownership. A variant's price and compareAtPrice are whatever the most recent successful write
said. Add a second or third writer working from its own snapshot and you get a timeline like this one, reconstructed from a real incident:
| Time (UTC) | Writer | What it sent | Resulting variant state |
|---|---|---|---|
| Fri 16:10 | Merchandiser in admin | price 89.00, compare-at 129.00 | On sale (correct) |
| Sat 02:00 | ERP nightly price sync | price 129.00, compare-at "0" (full snapshot) | Sale undone, compare-at 0.00 |
| Sat 02:15 | PIM export | compare-at 129.00 (stale snapshot) | price 129.00, compare-at 129.00 |
| Sat 02:16 | Flow: "tag on-sale if compare-at set" | adds tag on-sale | Lands in Sale collection at full price |
| Sun 02:00 | ERP again | compare-at "0" | Ping-pong continues nightly |
Each system is behaving "correctly" by its own logic. The store is wrong anyway. The common factors: full-snapshot writes, no field ownership, and automations that react to other automations.
3. Finding the last writer with Admin GraphQL 2026-10
Shopify does not store "who last wrote this price" on the variant. Attribution is a correlation exercise. We do it in four steps.
Step 1 — Capture the current state and timestamps
query VariantForensics($id: ID!) {
productVariant(id: $id) {
id sku price compareAtPrice updatedAt
product {
id title updatedAt
events(first: 15, sortKey: CREATED_AT, reverse: true) {
nodes {
createdAt message
... on BasicEvent { action appTitle attributeToApp attributeToUser }
}
}
}
}
}
appTitle and attributeToApp sometimes name the integration outright. Treat this as a lead, not proof: event coverage for
API-driven variant edits is uneven, and bulk operations may not leave a per-variant trail.
Step 2 — Log every products/update webhook with its headers
Store X-Shopify-Webhook-Id, X-Shopify-Triggered-At, the payload's updated_at, and each variant's
price and compare_at_price. The webhook does not say who made the change, but it gives you a precise timeline of when each value appeared.
Step 3 — Overlay writer job histories
Line up the webhook timeline against the ERP job queue entries, PIM export logs, Shopify Flow run history, Matrixify or CSV import history, and any
app that has write_products. The writer whose run finishes seconds before the bad value appears is your suspect. A "0"
arriving in a batch of 100+ variants within the same second is a strong bulk-operation fingerprint.
Step 4 — Confirm by isolation
Pause the suspect for one cycle (disable its job, not its credentials) and watch whether the overwrite still happens. Correlation without this step has sent more than one team chasing the wrong vendor.
4. Fix the architecture: one owner per field
- Write a field ownership matrix: e.g. ERP owns
priceand cost, merchandising (admin or PIM) ownscompareAtPrice, inventory belongs to the WMS. - Configure every non-owner to omit the field from its payloads, exactly as the BC fix does for unchanged compare-at prices.
- Clear compare-at prices with
null, never"0"or"0.00". - Stop Flow workflows from reacting to fields another automation writes, or gate them on a tag the owner sets.
- Keep nightly CSV re-imports out of fields an integration owns; import only the columns you intend to change.
5. A webhook circuit breaker that stops loops
Even with ownership fixed, any guard that writes back to Shopify needs two protections: ignore its own echoes, and stop writing when a variant is being fought over. This is the core of the pattern we run, trimmed for readability:
import crypto from "node:crypto";
const echoes = new Map(); // variantId -> { fp, until } our own writes, 60s TTL
const flips = new Map(); // variantId -> [timestamps] value changes seen
const fp = (v) => `${v.id}|${v.price}|${v.compare_at_price ?? "null"}`;
export function verifyHmac(rawBody, header, secret) {
const digest = crypto.createHmac("sha256", secret).update(rawBody).digest("base64");
const a = Buffer.from(digest), b = Buffer.from(header || "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
export async function onProductUpdate(product, { draftProduct, clearCompareAt, alert }) {
for (const v of product.variants) {
const echo = echoes.get(v.id);
if (echo && echo.fp === fp(v) && Date.now() < echo.until) continue; // our own write
const now = Date.now();
const recent = (flips.get(v.id) || []).filter((t) => now - t < 15 * 60_000);
recent.push(now); flips.set(v.id, recent);
if (recent.length >= 4) { // 4 changes in 15 min = a fight
await alert(`Circuit open on ${v.id}: writers are fighting. Automated writes paused.`);
continue; // do NOT write back
}
const price = Number(v.price), cmp = v.compare_at_price == null ? null : Number(v.compare_at_price);
if (!(price > 0)) {
await draftProduct(product.id);
echoes.set(v.id, { fp: fp(v), until: now + 60_000 });
} else if (cmp !== null && cmp <= price) {
await clearCompareAt(product.id, v.id); // send null, never "0"
echoes.set(v.id, { fp: fp({ ...v, compare_at_price: null }), until: now + 60_000 });
}
}
}
Two details matter in production. The fingerprint must describe the state after your write, otherwise the echo is not recognized and you start a loop yourself. And an open circuit must page a human: the breaker buys time, it does not resolve the conflict.
6. Diagnostic checklist
- Count variants with
compareAtPriceequal to0.00; a sudden jump points to a bulk writer. - Check whether the bad values appear only on large syncs (100+ records) — the BC signature.
- List every app and integration with
write_productsscope; you are often surprised by one. - Run the four forensic steps before you call any vendor.
- Deploy the circuit breaker in log-only mode for 48 hours before letting it write.
See how many variants are already affected
Export your products and drop the CSV into the free browser-local checker. Nothing leaves your browser; it lists $0 and unparseable prices and inverted compare-at prices (set, but lower than price), row by row. For compare-at values of exactly 0.00, use the export filter in our compare-at zero vs blank guide.
FAQ
Why does my ERP keep reverting prices I change in Shopify admin?
Shopify has no field-level ownership. Whichever system writes a variant last wins. If your ERP sends the full variant state on every sync, it overwrites manual admin edits, PIM updates and Flow changes with its own snapshot.
Is compareAtPrice "0" the same as an empty compare-at price in Shopify?
No. null means there is no compare-at price. "0" is stored as a real 0.00 value, which makes automated collection rules such as "compare-at price is not empty" match, and can confuse themes and feeds. Writers should send null to clear the field or omit it when unchanged.
Can Shopify tell me which app or integration last changed a price?
Not directly on the variant. Product events sometimes attribute changes to an app, but coverage for API edits is uneven. Reliable attribution comes from correlating products/update webhook timestamps with each writer's job history, then confirming by pausing one writer for a cycle.
How do I stop two integrations from fighting over the same price?
Assign each field exactly one owning system, make the other writers omit that field, and put a circuit breaker on your webhook handler that detects a variant flipping between two values and stops automated writes while alerting a human.