Helper class to access contexts and place error messages on attributes during groovy rule execution.
Field
Description
CHANNEL_PRODUCT
A ChannelProductContext-instance containing the current product during rule execution.
Attributes can be unwrapped using the following patterns: def product = GroovyExecutionScope.CHANNEL_PRODUCT.getProduct(); def attribute = product.getAttribute("ATTRIBUTE_ID");
followed by one of the following:
attribute.getValue() // get value of attribute as string attribute.getValue(String attributeId) // get nested attribute in composite attribute.getMultiValue() // get iterator over values (String) in multi valued attribute attribute.getMultiValue(int index) // get the index-th value (String) of multi valued attribute attribute.getMultiValue(String attributeId) // get iterator over nested attribute in composite in multi valued attribute attribute.getMultiValue(String attributeId, int index) // get nested attribute in the index-th composite in multi valued attribute
errors
A map containing (String attributeId, String errorMessage) key-value pairs. It can be used in one of the following ways:
GroovyExecutionScope.errors.put("ATTRIBUTE_ID", "Attribute has an error ... [add explanation]");
return !GroovyExecutionScope.errors.isEmpty();