Repository navigation
fix(api): configurable POST creates the variants it receives - #410
Merged
navneetkumar-pim-webkul merged 3 commits intoMay 26, 2026
Merged
navneetkumar-pim-webkul merged 3 commits into
navneetkumar-pim-webkul merged 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Admin API configurable product creation so POST /api/v1/rest/(configurable|configrable)-products no longer drops variants from the request payload, aligning the API-facing variant shape with the internal variant_<idx> format used by variant creation.
Changes:
- Whitelist
variantsinConfigurableProductController::store()and normalize[{sku, attributes:{...}}]into the internalvariants[variant_<idx>][values][common]structure. - Add a Pest regression test to ensure variants provided in the POST payload are created and linked to the configurable parent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/Webkul/AdminApi/src/Http/Controllers/API/Catalog/ConfigurableProductController.php | Accepts variants on configurable product creation and normalizes API payload into internal variant structure. |
| packages/Webkul/AdminApi/tests/Feature/Catalog/ApiVariantDetachmentTest.php | Adds regression coverage to ensure posted variants are created and attached to the parent product. |
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.
Summary
Fixes #841. POST
/api/v1/rest/configrable-productswithvariants: [{sku, attributes:{}}]silently dropped the variants — parent created,variants: [].Cause:
request()->only(...)whitelist missed'variants', and the API-facing shape differed from the internalvariant_<idx>shapecreateVariantexpects.Fix
'variants'torequest()->only(...)inConfigurableProductController::store.normalizeVariantsPayload()converts[{sku, attributes:{}}]→['variant_0' => {sku, values:{common:{...}}}].Test plan
ApiVariantDetachmentTest) — passes after fix