Hierarchies
Use hierarchies to organize your products into categories and sub-categories. Define hierarchies that work for the products in your store.
A hierarchy is a tree structure that consists of a root node with 1 or more parent nodes. Each parent node can also have one or more children nodes, and so on, creating a parent-child relationship between nodes.
A product can belong to multiple nodes in multiple hierarchies. The following example of Elpa basketball shoe for men shows different hierarchies and nodes that the product might be in:
- Brands > Elpa
- Shoppers > Men
- Shoes > Sports > Basketball
The root of a hierarchy specifies the aspect of the product data that the hierarchy displays. For example, root can be categories, brands, types, or manufacturers of the products. You cannot assign products to a root node.A node in a hierarchy contains products grouped in a specific theme, such as a products from a specific brand.
Characteristics of Hierarchies and Nodes
Below is an example of a hierarchy and its nodes.
- Sibling nodes are nodes with the same parent. Sibling nodes must have unique names and unique slugs. The nodes Electric Ranges and Gas Ranges are siblings. They must have unique names and slugs.
- Nodes that are in different locations in a hierarchy, or across multiple hierarchies, do not need unique names and slugs.
- If you move the Electric Ranges node to the Built-in node, all the children of the Electric Ranges node also move to the Built-in node.
- The Double Oven nodes can have the same name because they have different parents.
Once you have created your products, (for more information, see Products API or Hierarhies in Commerce Manager), you can use Hierarchies to organize your products.
- You can associate products with nodes. You cannot associate a product with the root node. For more information, see Create Node Product Relationships.
- 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. Any nodes in the existing hierarchy are also created in the duplicated hierarchy. In addition, you can optionally specify whether you want products associated with the nodes in an existing hierarchy to be associated with the nodes in the duplicated hierarchy. See Duplicate a Hierarchy.
- You can move an existing node to a different location within the same hierarchy by changing its parent node. If the node has child nodes, they retain their relationship with the moved node. In other words, the node and all its children move to the new location in the hierarchy. For more information, see Create a Node in a hierarchy.
- If your store supports multiple languages, you can localize new and existing hierarchies and nodes.
Creating Hierarchies and Nodes
You can create the Major Appliances hierarchy by performing the following steps.
- Using Create a Hierarchy, create a hierarchy whose name is Major Appliances. Each hierarchy has a hierarchy ID. In other words, the hierarchy ID is the ID of the root node.
- Using Create a Node in a hierarchy, create the following child nodes. When you create a node in a hierarchy, by default, the node is a child of the root node. Specify
sort_order
to configure the order of the nodes.- Ranges
- Refrigerators
- Dishwashers
- Using Create a Node in a hierarchy, create the Electric Ranges node, specifying Ranges as the parent node.
- Using Create a Node in a hierarchy, create the following nodes, specifying Electric Ranges as the parent node.
- Electric Ranges 24ˮ
- Electric Ranges 30ˮ
- Double Oven
- Using Create a Node in a hierarchy, create the Gas Ranges node, specifying Ranges as the parent node.
- Using Create a Node in a hierarchy, create the following nodes, specifying Gas Ranges as the parent node.
- Gas Ranges 24ˮ
- Gas Ranges 30ˮ
- Gas Ranges 32"
- Double Oven
- Using Create a Node in a hierarchy, create the following nodes, specifying Dishwashers as the parent node.
- Built-in
- Standalone
Hierarchies and Catalogs
The hierarchies determine which products appear in the catalog. When you create a catalog, you specify one or more hierarchies. Only the products that are associated with the selected hierarchies are included in the catalog. Your Front-end developers use the hierarchies to create and populate navigation menus in your storefront. You can improve how your customers search your store using the Catalog View API.
You can also specify the order you want your hierarchies to display in a published catalog. You can order your hierarchies on a catalog-by-catalog basis.
📄️ Create a hierarchy
Create a hierarchy
📄️ Get all hierarchies
Get all hierarchies
📄️ Get a hierarchy
Retrieves the specified hierarchy.
📄️ Update a hierarchy
Specify whichever attributes you want to change. The values of the other attributes remain the same. If the attributes section is empty, the hierarchy is not updated.
📄️ Delete a hierarchy
Deletes the specified hierarchy and all its children.
📄️ Create a node
Creates a node in the specified hierarchy.
📄️ Get all nodes in a hierarchy
A fully paginated view of all nodes in a hierarchy regardless of depth.
📄️ Get a node
Retrieves a node from a hierarchy.
📄️ Update a node
Updates the specified node in a hierarchy. You can do a partial update, where you specify only the field value to change.
📄️ Deletes a node
Deletes a node by the node ID
📄️ Get a hierarchy's children
Get a hierarchy's children
📄️ Create relationships between a node and child nodes
Use this endpoint to create relationships between a single parent node and one or more child nodes. You can create a relationship only if:
📄️ Get a node's children
Retrieves the child nodes for a specified node.
📄️ Update a node's parent
Changes the parent of the specified node. The new parent node must be located within the same hierarchy as the specified node.
📄️ Delete a node's parent
Delete a node's parent
📄️ Create a node's product relationships
Creates relationships between the specified node and one or more products in a specified hierarchy.
📄️ Deletes a node's product relationships
Deletes a node's product relationships
📄️ Get a node's products
Returns the products associated with the specified hierarchy node from a published catalog. Products must be in a live status. If the products have been curated using the update a hierarchy node endpoint, then the products are returned in the order specified in the `curated_products` attribute in the body of the update a hierarchy node request. A product that is curated has the 'curated_product': true attribute displayed.
📄️ Duplicate a hierarchy
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.