Duplicate a hierarchy
POST/pcm/hierarchies/:hierarchyID/duplicate_job
Using this option, you can duplicate an existing hierarchy. This is useful because it enables you to quickly and easily create multiple hierarchies with the same node structure.
When you duplicate a hierarchy, you can specify a new name and/or a new description for the duplicated hierarchy. All other attributes, such as slug and locales, stay the same.
Any nodes in the existing hierarchy are also replicated in the duplicated hierarchy. In addition, you can optionally use the include_products
attribute to specify whether you want products associated with the nodes in an existing hierarchy to be associated with the nodes in the duplicated hierarchy. By default, product associations in an existing hierarchy are not duplicated in a duplicate hierarchy.
Duplicating a hierarchy is an asynchronous operation. When you duplicate a hierarchy, a job is created. The jobId of the job is displayed in the response. When the job is complete, the duplicate hierarchy operation is also complete. You can use the jobId to see the status of your job using Get a Job.
Jobs are processed one at a time. You can continue to send duplicate hierarchy requests, but those jobs are queued. In other words, Commerce looks for any jobs that have a status of PENDING and starts the job with the earliest created date. This process is repeated until all jobs are processed.
Once the job is complete, run:
- Get all hierarchies to retrieve the HierarchyId of your duplicated hierarchy.
- Get a hierarchy to retrieve the nodes and (if applicable) products associated with the duplicated hierarchy.
Request
Path Parameters
A unique identifier for the hierarchy.
- application/json
Body
required
data object
Possible values: [hierarchy
]
This represents the type of resource object being returned. Always hierarchy
.
attributes object
The name of the duplicate hierarchy. The maximum length is 1000 characters.
A description of the duplicate hierarchy.
Specify true
if you want the product associations in the existing nodes associated in your duplicated hierarchy. If not, specify false
.
Responses
- 201
- 404
- 422
- 500
Successfully returns the duplicate hierarchy job ID
- application/json
- Schema
- Example (from schema)
- duplicated-hierarchy
Schema
pending
- Commerce has received the request but is currently busy processing other requests.started
- Commerce has started processing the job.success
- The job has successfully completed.failed
- The job has failed.
data object
A unique identifier generated when a job is created.
Possible values: [pim-job
]
This represents the type of resource object being returned. Always pim-job
.
attributes object
The date and time a job is started.
The date and time a job is completed.
The date and time a job is created.
The date and time a job is updated.
Possible values: [child-products
, product-import
, product-export
, hierarchy-duplicate
, price-import
]
The status of a job.
Possible values: [pending
, cancelled
, started
, success
, failed
]
meta object
Applies to all job types. A unique request ID is generated when a job is created.
Applies to hierarchy-duplicate
job types. The ID of the original hierarchy that you duplicated.
Applies to hierarchy-duplicate
job types. The duplicated hierarchy ID.
If the job type is product_export
, a link to the file is created when running a job.
The entities included in the job. For example, if the job type is product-export
, the PXM products included in the export.
{
"data": {
"id": "string",
"type": "pim-job",
"attributes": {
"started_at": "2020-09-22T09:00:00",
"completed_at": "2020-09-22T09:00:00",
"created_at": "2020-09-22T09:00:00",
"updated_at": "2020-09-22T09:00:00",
"type": "child-products",
"status": "pending"
},
"meta": {
"x_request_id": "string",
"copied_from": "string",
"hierarchy_id": "string",
"file_locations": [
"string"
],
"filter": "string"
}
}
}
{
"data": {
"type": "pim-job",
"id": "1d9b101e-a40a-4e53-9f54-08a9ede65019",
"attributes": {
"completed_at": null,
"created_at": "2024-01-11T22:49:10.338Z",
"started_at": null,
"status": "pending",
"type": "hierarchy-duplicate",
"updated_at": "2024-01-11T22:49:10.338Z"
},
"meta": {
"x_request_id": "40995a1d-c0c1-4d52-a178-bfb5399ab0ec"
}
}
}
Bad Request. Not Found.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Not Found",
"status": "404"
}
]
}
Bad request. The request failed validation.
- application/json
- Schema
- Example (from schema)
- failed-validation
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Failed Validation",
"status": "422",
"detail": "<XYZ> can not be empty"
}
]
}
Internal server error. There was a system failure in the platform.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors undefined[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": "500",
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"status": "500",
"title": "Internal Server Error",
"detail": "There was an internal server error, you can report with your request id.",
"request_id": "635da56d-75a1-43cd-b696-7ab119756b3a"
}
]
}