Skip to content

feat: support setSku and setProductVariantKey on products - #464

Open
tleguijt wants to merge 2 commits into
mainfrom
feature/additional-product-actions
Open

tleguijt wants to merge 2 commits into
mainfrom
feature/additional-product-actions

Conversation

@tleguijt

@tleguijt tleguijt commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Support the setSku and setProductVariantKey product update actions, so a variant's SKU or key can be changed on the staged projection, or on both projections with staged: false.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:43
@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1578b3d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@labdigital/commercetools-mock Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Product variant updates allow duplicate SKUs and keys, fail when staged and current SKUs diverge, and incorrectly flag clearing absent fields as staged changes.

4 open issues
What changed in this PR

Adds setSku and setProductVariantKey to the mock commercetools Product API, allowing variant identifiers to be updated without recreating products.

Changes:

  • Adds handlers for staged-only updates by default and both projections with staged: false.
  • Adds service tests for successful updates and an unknown variant.
  • Adds a minor-release changeset.
File Description
src/​services/​product.test.ts Tests both actions and unknown-variant rejection for setSku.
src/​repositories/​product/​actions.ts Implements SKU and variant-key updates with staged-change tracking.
.changeset/​product-set-sku-and-variant-key.md Documents the new actions for a minor release.

Review effort: Balanced

Comment thread src/repositories/product/actions.ts Outdated
Comment on lines +987 to +992
const setVariantKey = (data: Writable<ProductData>) => {
const { variant, isMasterVariant, variantIndex } = getVariant(
data,
variantId,
sku,
);
);
}

variant.key = key;
);
}

variant.key = key;
);
}

variant.sku = sku;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants