[Shopify] Fix Product Sync deleting mapped variants on stale Updated At timestamp#9313
Merged
mazhelez merged 1 commit intoJul 13, 2026
Merged
Conversation
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
Contributor
Copilot PR ReviewIteration 1 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
onbuyuka
enabled auto-merge
July 10, 2026 11:41
darjoo
approved these changes
Jul 13, 2026
AndreiPanko
approved these changes
Jul 13, 2026
mazhelez
disabled auto-merge
July 13, 2026 09:25
mazhelez
deleted the
bugs/641922-shopify-variant-delete-on-stale-timestamp
branch
July 13, 2026 09:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:UpdateShopifyVariantFieldsreturnsfalseto mean "skip — the local record is already up to date".RetrieveShopifyVariantpassed thatfalsestraight through, and its callerShpfyProductImport.SetProductinterpretedfalseas "variant no longer exists" and calledShopifyVariant.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 seesShopify updatedAt < local Updated At, the guard trips, and the variant is deleted. On the next sync it is re-created with a nullItem SystemId, so for Default Title products theItem No.FlowField becomes blank.Fix
RetrieveShopifyVariantnow returnstruewhenever theproductVariantnode is present in the response (the variant still exists on Shopify), andfalseonly 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.UpdateShopifyVariantFieldsno longer returns aBoolean— its only caller ignored the value after the change.Test plan
Added
Shpfy Variant API Test(codeunit 139613) with[HttpClientHandler]-based mocking:UnitTestRetrieveShopifyVariantKeepsVariantWhenLocalUpdatedAtIsAhead— localUpdated Atset ahead of Shopify'supdatedAt; asserts the variant is reported as existing (not deleted) and the local timestamp is preserved (guard skipped the update).UnitTestRetrieveShopifyVariantReportsMissingWhenDeletedOnShopify— Shopify returns a nullproductVariantnode; asserts the variant is reported as missing so the caller may delete it.