Configure Child or Grandchild Products Based on Parent Product

Use the parent keyword to configure child and grandchild products dynamically based on the parent product.

Use the parent keyword to configure child and grandchild products dynamically based on the parent product. Control visibility or availability for the child or grandchild using the keyword.

The parent keyword isn’t supported with Group Type. When you organize components in Product Component Groups, the Group Type becomes an intermediate parent in the hierarchy. To reach the bundle root, use parent(attribute, 1) to skip the group, or use the dot-notation pattern from the bundle level, groupVariable.childRelation.attribute, instead of parent(). See Group Type.

Note

In this example, grandchild products are excluded based on which parent product they belong to.

1type LineItem;
2
3/*
4 * Parent 1: Industrial Bundle
5 * Sets the context 'ApplicationType' to "Industrial"
6 */
7type IndustrialGeneratorBundle : LineItem {
8    relation enclosurePackage : EnclosurePackage[1..999];
9
10    relation enclosurePackage1 : EnclosurePackage[1..999];
11
12    relation enclosurePackage2 : EnclosurePackage;
13
14    string ApplicationType = "Industrial";
15}
16
17/*
18 * Parent 2: Residential Bundle
19 * Sets the context 'ApplicationType' to "Residential"
20 */
21type ResidentialGeneratorBundle : LineItem {
22    relation enclosurePackage3 : EnclosurePackage[1..999];
23
24    relation enclosurePackage4 : EnclosurePackage;
25
26    string ApplicationType = "Residential";
27}
28
29/*
30 * Shared Component: Enclosure Package
31 * Uses parent() to read the ApplicationType and excludes items accordingly.
32 */
33type EnclosurePackage : LineItem {
34    relation soundInsulation : SoundInsulation[0..999];
35    relation weatherProofing : WeatherProofing[0..999];
36    relation heater : Heater[0..999];
37    relation lighting : InternalLighting[0..999];
38
39// Retrieve the context tag from the parent bundle
40    string parentApp = parent(ApplicationType);
41
42    message(true, parentApp);
43
44    // Logic 1: Exclude Lighting and Heater for BOTH bundles
45    exclude(parentApp == "Industrial" || parentApp == "Residential", lighting[InternalLighting]);
46    exclude(parentApp == "Industrial" || parentApp == "Residential", heater[Heater]);
47
48    // Logic 2: Residential (Basic) excludes Sound Insulation
49    exclude(parentApp == "Residential", soundInsulation[SoundInsulation]);
50
51    // Logic 3: Industrial (Pro) excludes Weather Proofing
52    exclude(parentApp == "Industrial", weatherProofing[WeatherProofing]);
53}
54
55// --- Sub-components ---
56
57type SoundInsulation : LineItem {
58    @(defaultValue = "Foam")
59    string Material = ["Foam", "Fiberglass"];
60}
61
62type WeatherProofing : LineItem {
63    @(defaultValue = "Standard")
64    string Grade = ["Standard", "Marine"];
65}
66
67type Heater : LineItem;
68
69type InternalLighting : LineItem;