66 lines
1.8 KiB
Markdown
66 lines
1.8 KiB
Markdown
# `POST /article/{sku}/parent`
|
|
|
|
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
|
|
|
Toggle parent mode for an article
|
|
|
|
Enables or disables parent article status. Enabling requires specifying an
|
|
attributeNameId; disabling requires the article to have zero children.
|
|
|
|
`attributeNameId` is **conditionally required**: it is optional in the schema
|
|
because it is only required when `isParent` is `true`. Omitting it (or passing
|
|
`0`/a negative value) together with `isParent: true` returns `400`
|
|
`attributeNameId is required to become a parent article`. It must not be sent
|
|
when `isParent` is `false`.
|
|
|
|
|
|
## Path parameters
|
|
|
|
| Param | Required | Type | Description |
|
|
|-------|----------|------|-------------|
|
|
| `sku` | yes | string | Article SKU |
|
|
|
|
## Body (JSON)
|
|
|
|
| Field | Required | Type | Description |
|
|
|-------|----------|------|-------------|
|
|
| `isParent` | yes | boolean | True to make article a parent, false to revert to regular article |
|
|
| `attributeNameId` | no | integer | **Conditionally required when `isParent` is `true`** (required iff isParent=true). The attributename id used for the article's variants. Omitting it while enabling parent mode returns 400. Must be omitted when `isParent` is `false`. |
|
|
|
|
```json
|
|
{
|
|
"isParent": true,
|
|
"attributeNameId": 1
|
|
}
|
|
```
|
|
|
|
## Response `200`
|
|
|
|
Updated article
|
|
|
|
```json
|
|
{
|
|
"article": {
|
|
"id": 1,
|
|
"categoryId": 1,
|
|
"name": "…",
|
|
"sku": "…",
|
|
"track_stock": true
|
|
}
|
|
}
|
|
```
|
|
|
|
## Errors
|
|
|
|
| Status | Description |
|
|
|--------|-------------|
|
|
| 400 | Invalid input, `attributeNameId` missing while `isParent` is true, article still
|
|
has children, article has stock/suppliers/a Stückliste/options, or the attribute is
|
|
already used by an ancestor parent article.
|
|
|
|
|
| 404 | Article or attribute name not found |
|
|
|
|
---
|
|
|
|
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|