Product Administration Guide > Customizable Product Scripts >
About Product Path
The product path is the path from the root of a customizable product to a component product within it. The path is a string that specifies the customizable product root and all relationship names leading to the component product. All or part of the product path are arguments to several scripting methods.
The syntax for product paths is as follows:
$.[Root Product]#1.[Relationship]#[Component Product]
Observe the following guidelines for product paths:
- The $ before .[Root Product] refers to a special configuration object called the basket. The basket contains all the objects in the customizable product.
- The #1 after [Root Product] refers to the first instance of the root product in the basket.
- Use a dot (.) to specify a relationship.
- Use a # to specify a component product within a relationship.
- Enclose relationship names and component product names in square brackets
([ ]). Use product name syntax to specify the name of a component product.
- All paths must end with a product name.
Figure 14 shows the structure of customizable product CP1.
Customizable product CP1 has two relationships R1 and R2. Relationship R1 contains two component products P1 and P2. Relationship R2 contains the customizable product CP2. CP2 contains one relationship R3, which has two component products P3 and P4.
The product paths for this customizable product are as follows:
- For P1. $.[CP1]#1.[R1]#[P1]
- For P2. $.[CP1]#1.[R1]#[P2]
- For CP2. $.[CP1]#1.[R2]#[CP2]
- For P3. $.[CP1]#1.[R2]#[CP2].[R3]#[P3]
- For P4. $.[CP1]#1.[R2]#[CP2].[R3]#[P4]
Here are examples of using product paths in script methods:
- To add 1 P1:
AddItem("$.[CP1]#1", "R1", "P1", "1")
- To add 1 P3:
AddItem("$.[CP1]#1.[R2]#[CP2]", "R3", "P3", "1")
- To reduce the quantity of P3 to 0:
- To set the attribute Color to Red for P1:
SetAttribute("$.[CP1]#1.[R1]#[P1]", "Color", "Red")