Skip to content

[Shopify] Fix Product Sync deleting mapped variants on stale Updated At timestamp#9313

Merged
mazhelez merged 1 commit into
mainfrom
bugs/641922-shopify-variant-delete-on-stale-timestamp
Jul 13, 2026
Merged

[Shopify] Fix Product Sync deleting mapped variants on stale Updated At timestamp#9313
mazhelez merged 1 commit into
mainfrom
bugs/641922-shopify-variant-delete-on-stale-timestamp

Conversation

@onbuyuka

@onbuyuka onbuyuka commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#641922

Summary

Product Sync (Shopify → BC) could incorrectly delete a mapped variant when a bulk price export had stamped the local "Updated At" with CurrentDateTime() before Shopify's asynchronous bulk operation completed.

The root cause is a conflation of two meanings in RetrieveShopifyVariant:

  • The timestamp guard in UpdateShopifyVariantFields returns false to mean "skip — the local record is already up to date".
  • RetrieveShopifyVariant passed that false straight through, and its caller ShpfyProductImport.SetProduct interpreted false as "variant no longer exists" and called ShopifyVariant.Delete().

During the window between a bulk price export stamping the local timestamp (CurrentDateTime()) and Shopify actually processing the queued mutation, a Shopify→BC sync sees Shopify updatedAt < local Updated At, the guard trips, and the variant is deleted. On the next sync it is re-created with a null Item SystemId, so for Default Title products the Item No. FlowField becomes blank.

Fix

  • RetrieveShopifyVariant now returns true whenever the productVariant node is present in the response (the variant still exists on Shopify), and false only when the node is genuinely absent (variant deleted on Shopify). The timestamp guard still skips the field update, but that skip no longer signals a deletion.
  • UpdateShopifyVariantFields no longer returns a Boolean — its only caller ignored the value after the change.

Test plan

Added Shpfy Variant API Test (codeunit 139613) with [HttpClientHandler]-based mocking:

  • UnitTestRetrieveShopifyVariantKeepsVariantWhenLocalUpdatedAtIsAhead — local Updated At set ahead of Shopify's updatedAt; asserts the variant is reported as existing (not deleted) and the local timestamp is preserved (guard skipped the update).
  • UnitTestRetrieveShopifyVariantReportsMissingWhenDeletedOnShopify — Shopify returns a null productVariant node; asserts the variant is reported as missing so the caller may delete it.

Product Sync (Shopify to BC) incorrectly deleted mapped variants when a
bulk price export stamped the local "Updated At" with CurrentDateTime()
before Shopify's async bulk operation completed. RetrieveShopifyVariant
returned the timestamp guard's "skip, already up to date" false as if it
meant "variant no longer exists", so the caller in SetProduct deleted the
variant. On re-creation the variant lost its Item SystemId mapping.

RetrieveShopifyVariant now returns true whenever the productVariant node
is present (variant still exists on Shopify), and false only when the node
is absent (variant genuinely deleted). UpdateShopifyVariantFields no longer
returns a Boolean since its only caller ignored it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: de2f2b06-bf08-4098-98fa-9bb5c73cba80
@onbuyuka
onbuyuka requested a review from a team July 10, 2026 11:03
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jul 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 1 · Outcome: completed

All sub-skills ran (upgrade and ui declined as not-applicable — no upgrade/install/schema surface and no page/control-add-in UI files in the diff); no knowledge-file or agent findings met the emission bar for the remaining domains.

Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630

Orchestrator pre-filter (13 file(s) excluded)

  • layer-disabled (knowledge) : 13 file(s)

Findings produced by the Copilot CLI agent against BCQuality at 822cae1b2771ac25f665f73369f69093bd4fd630. Reply 👎 on any inline comment to flag false positives.

@onbuyuka
onbuyuka enabled auto-merge July 10, 2026 11:41
@mazhelez
mazhelez disabled auto-merge July 13, 2026 09:25
@mazhelez
mazhelez merged commit 210794a into main Jul 13, 2026
327 of 334 checks passed
@mazhelez
mazhelez deleted the bugs/641922-shopify-variant-delete-on-stale-timestamp branch July 13, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants