Skip to main content

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

Responses

Successfully returns the duplicate hierarchy job ID