[Backport releases/28.x] Fix #7622 Shopify product export child-item variant handling#8615
[Backport releases/28.x] Fix #7622 Shopify product export child-item variant handling#8615tVisionDeb wants to merge 2 commits into
Conversation
…microsoft#7689) Fixes microsoft#7622 Fixes an issue where product export could continue processing variants on a child item after handling an existing Shopify variant created through "Add Item as Shopify Variant". - Re-fetch the parent item before the item variant loop in `Shpfy Product Export`. - Add a regression test for the child-item variant scenario. - Add a test subscriber that mocks Shopify GraphQL responses and verifies that no unexpected variant create call is made. - Validated in a clean local W1 container. - Passed `Codeunit 139616 Shpfy Product Export 7622 Test`. Fixes [AB#632757](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/632757)
|
Issue #7622 is not valid. Please make sure you link an issue that exists, is open and is approved. |
[HttpClientHandler] requires HttpClient.Send() to be called, but CreateShop() sets IsTestInProgress = true on the SingleInstance CommunicationMgt, redirecting HTTP calls through the old OnClientSend/OnGetContent event system. Without subscribers to those events the response is empty, causing 'no JSON' for every productUpdate call. Call SetTestInProgress(false) in InitializeProductExport() before the export runs, matching the pattern already used in ShpfyCreateItemAPITest.
|
This PR is mostly a straight backport of #7689, but one additional fix was needed for the test to pass in 28.x CI. Additional fix (commit e878f5e): The test uses [HttpClientHandler]\ for HTTP mocking, but \Shpfy Communication Mgt.\ (codeunit 30103) is declared \SingleInstance = true. Every call to \CreateShop()\ sets \IsTestInProgress = true\ on that singleton, which routes all HTTP calls through the old \OnClientSend/\OnGetContent\ event system instead of \HttpClient.Send(). Since [HttpClientHandler]\ only intercepts at \HttpClient.Send(), no mock response was ever set - resulting in the empty response that caused the 'no JSON for productUpdate' CI failure across all 17 locales. The fix adds \CommunicationMgt.SetTestInProgress(false)\ to \InitializeProductExport(), matching the existing pattern in \ShpfyCreateItemAPITest\ (which has the comment 'Disable Event Mocking' for exactly this reason). The original test was validated in an isolated codeunit where \CreateShop()\ had not previously been called; when merged into the existing codeunit 139601 the singleton state from earlier tests in the same session caused the failure. |
|
To add context on the testing approach: the Shopify connector originally mocked HTTP via event subscribers on \OnClientSend/\OnGetContent, controlled by the \IsTestInProgress\ flag. Newer test codeunits (written after BC introduced [HttpClientHandler]) call \SetTestInProgress(false)\ explicitly to opt out of the old event system - you can see the pattern in \ShpfyCreateItemAPITest\ and others. In main, the test for #7689 was written in a fresh codeunit that started with a clean singleton state. In this backport it was placed into the existing codeunit 139601, which was written before the [HttpClientHandler]\ pattern existed and whose setup code never resets the flag. The 28.x backport therefore straddles the transition between the two approaches, and the \SetTestInProgress(false)\ call is the bridge. |
Summary
Backport of PR #7689 (merged to
microsoft:mainon 29 April 2026).Cherry-picks the fix for issue #7622 onto
releases/28.x. The fix prevents Shopify product export from creating unwanted variants for items that were added as a Shopify variant via the child-item mapping.HS Code / tariff tests (part of a separate feature not present in
releases/28.x) were excluded from the cherry-pick as they are unrelated to this fix.Work Item(s)
Fixes AB#4326