Skip to main content

Create relationships between a node and child nodes

POST 

/pcm/hierarchies/:hierarchyID/nodes/:nodeID/relationships/children

Use this endpoint to create relationships between a single parent node and one or more child nodes. You can create a relationship only if:

  • The parent node already exists.
  • All child nodes already exist.
  • Every child node in the body of the request exists in the same hierarchy as the parent node.
  • A node is not a parent of itself. An array of child nodes request body must not contain the ID of the parent node in the path.
  • All siblings in a hierarchy must have a unique slug. Siblings are the child nodes that are related to the same parent.

Sort Order

You can also provide sort_order information when you create a relationship by adding a meta object to the array of node reference objects for each child node that requires sorting.

The node with the highest value of sort_order appears at the top of the response. For example, a node with a sort_order value of 3 appears before a node with a sort_order value of 2.

  • If you don’t provide sort_order when creating relationships, all child nodes in the response for Get a Node’s Children request are ordered by the updated_at time in descending order. The most recently updated child node appears at the top of the response.
  • If you set sort_order for only a few child nodes or not all, the child nodes with sort_order value appear first in the response and then other child nodes appear in the order of updated_at time.

You can also specify a sort_order when creating and updating a node.

  • If you create or update a node (Node A) with a sort_order and then you create a relationship for Node A with another node (Node B), the sort_order you specified when creating\updating Node A is overwritten.
  • If you create\update Node A and then you create a relationship with Node B but do not configure a sort_order, the sort_order you specified when you created\updated Node A is not overwritten.

Request

Path Parameters

    hierarchyID stringrequired

    A unique identifier for the hierarchy.

    nodeID stringrequired

    A unique identifier for the node.

Body

    data object[]
  • Array [
  • id stringrequired

    The unique identifier of the child node. Must not match the node ID specified in the request path.

    type stringrequired

    Possible values: [node]

    This represents the type of resource object being returned. Always node.

  • ]

Responses

Successfully returns the node's children

Schema
    data object
    id string

    The unique identifier of a node.

    type string

    Possible values: [node]

    This represents the type of resource object being returned. Always node.

    attributes object
    name string

    The name of the node, such as Ranges or Refrigerators. Names must be unique among sibling nodes in the hierarchy. Otherwise, a name can be non-unique within the hierarchy and across multiple hierarchies.

    description string

    A description for a node.

    slug string

    A slug for the node. Slugs must be unique among sibling nodes in the hierarchy. Otherwise, a slug can be non-unique within the hierarchy and across multiple hierarchies.

    curated_products string[]

    You can curate your products in your nodes product lists. Product curation allows you to promote specific products within each node in a hierarchy, enabling you to create unique product collections in your storefront.

    locales object

    Product Experience Manager supports localization of hierarchies and nodes. If you store supports multiple languages, you can localize hierarchy and node names and descriptions.

    property name* object

    A three-letter language code that represents the name of language you have used.

    name string

    A localized hierarchy or node name.

    description string

    A localized hierarchy or node description.

    relationships object

    Relationships allow you to move between requests. Includes links to the child nodes and products associated with a hierarchy or node.

    children object

    The child nodes related to the resource.

    data array

    An array of child nodes.

    links object

    Links allow you to move between requests.

    related string

    A link to a related resource.

    parent object

    The parent node related to the resource

    data object

    The parent node

    type stringrequired

    Possible values: [node]

    This represents the type of resource object being returned. Always node.

    id stringrequired

    The unique identifier of a node.

    products object

    The products related to the resource.

    data array

    An array of products.

    links object

    Links allow you to move between requests.

    related string

    A link to a related resource.

    meta object
    sort_order integer

    The sort order value. The node with the highest value of sort_order is displayed first. For example, a node with a sort_order value of 3 appears before a node with a sort_order value of 2. See Sorting Nodes in a hierarchy.

    created_at date-time

    The date and time a node is created.

    updated_at date-time

    The date and time a node was updated.

    parent_name string

    The name of the parent of the node if one exists.

    owner string

    Possible values: [store, organization]

    The node owner, either organization or store.

Loading...