Skip to content

[Shopify] Sync HS Code and Country of Origin on variant export#7414

Merged
onbuyuka merged 11 commits intomainfrom
private/onbuyuka/shpfyagenticplan
Apr 27, 2026
Merged

[Shopify] Sync HS Code and Country of Origin on variant export#7414
onbuyuka merged 11 commits intomainfrom
private/onbuyuka/shpfyagenticplan

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented Mar 26, 2026

Summary

Addresses gaps identified in the Shopify Agentic Plan Product Sync Guide to ensure BC product catalogs meet the data requirements for AI channel distribution.

  • Harmonized System Code: Sync Item."Tariff No." as harmonizedSystemCode on variant export (both create and update paths)
  • Country of Origin: Sync Item."Country/Region of Origin Code" as countryCodeOfOrigin on variant export
  • New fields added to Shpfy Variant table and populated in CreateTempProduct (4 code paths) and FillInProductVariantData (3 overloads)
  • New Sync HS Code and Country of Origin boolean on the Shop card (default on) gates the variant-field population, matching the pattern used by Sync Item Extended Text / Marketing Text / Attributes
  • Tests added for HS code and country of origin field population

Related docs PR for External URL extensibility example: MicrosoftDocs/dynamics365smb-devitpro#7259

Fixes AB#632223

@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Mar 26, 2026
- Add Tariff No. and Country/Region of Origin Code fields to Shpfy Variant table
- Populate HS code and country of origin from Item during product creation and export
- Include harmonizedSystemCode and countryCodeOfOrigin in variant CREATE and UPDATE GraphQL mutations
- Add open-source ExternalURL extension app that syncs external_url variant metafields via configurable URL template
- Add tests for HS code and country of origin on product creation

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@onbuyuka onbuyuka force-pushed the private/onbuyuka/shpfyagenticplan branch from a6adf52 to c4f49ff Compare March 26, 2026 20:52
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AL Documentation Audit

Documentation gaps were detected in the following apps:

  • Shopify-Connector-Test: 0% documentation coverage
  • Shopify-External-URL: 0% documentation coverage

To generate documentation, run /al-docs init or /al-docs update using GitHub Copilot CLI or Claude Code.
This review is for awareness to help keep documentation in sync with code changes. It is okay to dismiss this request.

onbuyuka and others added 4 commits March 30, 2026 10:24
Shopify rejects external_url metafield values without a scheme (protocol).
Added OnValidate trigger to error if template doesn't start with https:// or http://.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…bility example

The external_url metafield extension is now documented as a step-by-step
extensibility example in the Extending Shopify docs page. Source code is
not shipped; partners build it as a PTE from the documentation.

See: MicrosoftDocs/dynamics365smb-devitpro#7259

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@onbuyuka onbuyuka changed the title [Shopify] Add HS Code sync and External URL extension for Agentic Plan [Shopify] Sync HS Code and Country of Origin on variant export Mar 30, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

Comment thread src/Apps/W1/Shopify/App/src/Products/Codeunits/ShpfyProductExport.Codeunit.al Outdated
Look up Country/Region table and use ISO Code instead of raw BC
country code when populating countryCodeOfOrigin for Shopify GraphQL.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@onbuyuka onbuyuka force-pushed the private/onbuyuka/shpfyagenticplan branch from 97adff9 to a1dae30 Compare April 7, 2026 21:53
@github-actions github-actions Bot added this to the Version 29.0 milestone Apr 23, 2026
onbuyuka and others added 3 commits April 23, 2026 10:39
Add "Sync HS Code and Country" boolean on Shpfy Shop (field 209,
default on) and gate all variant-field assignments and GraphQL
fragments in Create/Update paths so the fields are only sent when
the shop opts in.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The write-layer gates in ShpfyCreateProduct and ShpfyProductExport
already prevent the fields from being populated when the toggle is off,
so the existing empty/diff checks in VariantAPI short-circuit naturally.
Matches the codebase pattern for Sync Item Extended Text / Marketing
Text / Attributes (single gate at write layer).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Resolve conflict in ShpfyShop.Table.al: main added fields 207/208
(Advanced Shopify Plan, Find Mapping by Barcode); keep both and
place the new field 209 (Sync HS Code and Country) after them.
@onbuyuka onbuyuka marked this pull request as ready for review April 23, 2026 09:04
@onbuyuka onbuyuka requested a review from a team as a code owner April 23, 2026 09:04
Copilot AI review requested due to automatic review settings April 23, 2026 09:04
@onbuyuka onbuyuka enabled auto-merge (squash) April 23, 2026 09:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Shopify product sync to include customs-related variant data (HS code and country of origin) so exported variants meet Shopify/AI channel distribution requirements.

Changes:

  • Adds Tariff No. and Country/Region of Origin Code fields to Shpfy Variant and populates them during variant creation/export when enabled.
  • Introduces a new shop setting Sync HS Code and Country of Origin (default on) and surfaces it on the Shop Card.
  • Updates Shopify GraphQL variant mutations to send harmonizedSystemCode and countryCodeOfOrigin, and adds unit tests for field population.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Apps/W1/Shopify/Test/Products/ShpfyCreateProductTest.Codeunit.al Adds tests validating HS code and country of origin population on temp variants.
src/Apps/W1/Shopify/App/src/Products/Tables/ShpfyVariant.Table.al Adds new persisted fields on the Shopify Variant table for HS code and origin country.
src/Apps/W1/Shopify/App/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al Extends GraphQL mutation payloads to include harmonizedSystemCode and countryCodeOfOrigin.
src/Apps/W1/Shopify/App/src/Products/Codeunits/ShpfyProductExport.Codeunit.al Populates the new variant fields during export and adds GetCountryISOCode helper.
src/Apps/W1/Shopify/App/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al Populates the new variant fields during temp product/variant creation paths.
src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al Adds a new shop-level boolean to gate syncing HS code and country of origin.
src/Apps/W1/Shopify/App/src/Base/Pages/ShpfyShopCard.Page.al Exposes the new shop setting on the Shop Card UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Apps/W1/Shopify/App/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al Outdated
Comment thread src/Apps/W1/Shopify/App/src/Products/Tables/ShpfyVariant.Table.al Outdated
Comment thread src/Apps/W1/Shopify/Test/Products/ShpfyCreateProductTest.Codeunit.al Outdated
onbuyuka and others added 2 commits April 23, 2026 13:27
- Outer inventoryItem guard in UpdateProductVariantGraphQLQuery now
  includes Tariff No. and Country/Region of Origin Code, so changing
  only those fields actually emits the inventoryItem payload.
- Align DataClassification on Tariff No./Country fields with the rest
  of Shpfy Variant (CustomerContent).
- Make the 3 new tests explicitly set Shop.\"Sync HS Code and Country\"
  in their GIVEN blocks rather than relying on InitValue=true.
- Rename UnitTestCreateTempProductWithVariantsSetsHSCode to also
  mention Country of Origin since the test asserts both fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Clearing Country/Region of Origin Code on an Item previously caused
the update mutation to emit 'countryCodeOfOrigin: ' with no value,
which Shopify rejects as a parse error. Emit 'null' explicitly to
clear the field instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment thread src/Apps/W1/Shopify/App/src/Products/Tables/ShpfyVariant.Table.al
@github-actions
Copy link
Copy Markdown

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@onbuyuka onbuyuka closed this Apr 27, 2026
auto-merge was automatically disabled April 27, 2026 10:29

Pull request was closed

@onbuyuka onbuyuka reopened this Apr 27, 2026
@onbuyuka onbuyuka enabled auto-merge (squash) April 27, 2026 10:29
@onbuyuka onbuyuka merged commit 0313434 into main Apr 27, 2026
90 of 94 checks passed
@onbuyuka onbuyuka deleted the private/onbuyuka/shpfyagenticplan branch April 27, 2026 17:02
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.

5 participants