Skip to content

[Backport releases/28.x] Fix #7622 Shopify product export child-item variant handling#8615

Open
tVisionDeb wants to merge 2 commits into
microsoft:releases/28.xfrom
tVisionDeb:backport/releases/28.x/7622
Open

[Backport releases/28.x] Fix #7622 Shopify product export child-item variant handling#8615
tVisionDeb wants to merge 2 commits into
microsoft:releases/28.xfrom
tVisionDeb:backport/releases/28.x/7622

Conversation

@tVisionDeb

@tVisionDeb tVisionDeb commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of PR #7689 (merged to microsoft:main on 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

…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)
@tVisionDeb tVisionDeb requested a review from a team as a code owner June 15, 2026 16:01
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Issue #7622 is not valid. Please make sure you link an issue that exists, is open and is approved.

@github-actions github-actions Bot added the Linked Issue is linked to a Azure Boards work item label Jun 15, 2026
@github-actions github-actions Bot added this to the Version 28.3 milestone Jun 15, 2026
@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jun 15, 2026
@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Jun 18, 2026
@github-actions github-actions Bot removed the needs-approval Workflow runs require maintainer approval to start label Jun 18, 2026
onbuyuka
onbuyuka previously approved these changes Jun 18, 2026
[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.
@tVisionDeb tVisionDeb requested a review from a team June 18, 2026 16:41
@tVisionDeb

Copy link
Copy Markdown
Contributor Author

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.

@tVisionDeb

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the needs-approval Workflow runs require maintainer approval to start label Jun 18, 2026
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 From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item needs-approval Workflow runs require maintainer approval to start

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants