Expand my Community achievements bar.

InheritanceValueMap is not working for node

Avatar

Level 1

Hi,

I have some product variation node under /etc/commerce/products and resource type of node is

sling:resourceType

String

commerce/components/product

I am trying to get value from these nodes using InheritanceValueMap but its not working while Parent have the property which i am accessing.

Parent.pngParent Node

child.pngChild Node

Here is my code

            final Resource prodRes = resourceResolver.getResource("/etc/commerce/products/XXXX/XX/XX/XX/BES870CBXL/BES870CBXL");

            final InheritanceValueMap inVM = new HierarchyNodeInheritanceValueMap(prodRes);

            final String bcode = inVM.getInherited("price", "");

Please provide suggestion if i am doing anything wrong.

1 Reply

Avatar

Level 10

HierarchyNodeInheritanceValueMap does not return the inherited value from parent node....but from the parent page. So it won't work in your case.

If you have a structure like

Parent - /content/pageA/jcr:content - key = value

Child - /content/pageA/pageB/jcr:content

In this case, parent key will be inherited on the child page.

You can also find the explanation in documentation: https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co... 

1365130_pastedImage_10.png

thanks