Understand PMDL discount rules
The Price Model Definition Language (PMDL) describes Oracle CX Commerce promotions internally.
PMDL describes the rules for when a promotion may apply (the condition), the rules for what may be discounted (the offer), and how to apply the discount (for example, 10% off).
This section describes the XML used for constructing discount rules that represent promotions in Oracle CX Commerce.
PMDL XML structure
The PMDL that describes promotions discount rules is relatively simple. The DTD defines the following to use in your PMDL rules:
- Iterators such as
next,up-to-and-includingandevery. - Quantifiers that are used in
WHENconditions, such asat-least,at-most,exactlyandall. - Operators such as
and,orandnot. - Comparators such as
starts-with,ends-with,contains,greater-than,less-than and equals, which compare values and/or arrays. - Operations such as
unionandanded-union. - Value types such as
constantor null. - Array types such as
constantorvalue.
The PMDL DTD contains the following elements:
Pricing-Model element
The pricing-model element is the root tag for the PMDL.
Offer element
Every pricing-model requires one offer element. The
offer includes one or more discount-structure elements, which
contain detailed information about the discount and its target.
You can include more than one discount-structure element in an
offer; this allows you to wrap multiple discounts in a single promotion (note that this is not
supported in Merchandising, but you can build a custom template with this functionality).
If you have multiple discount structures within a single item promotion, you can
specify the filter-collection-name attribute of the offer;
this ensures that once a given item has been marked to receive a discount, it cannot receive a
discount from any other discount-structures. If
filter-collection-name is not set, filtering does not take place, and a given
commerce item can be the target for more than one discount. The
filter-collection-name should match the iterator element’s
collection-name attribute, which is normally set to items.
Filtering is not required for single discount structures, or for non-item-based promotions.
Qualifier Element
Every pricing-model requires one qualifier
element. The qualifier is the root tag for the promotion’s buy
condition.
Target Element
The target specifies the rule for selecting the items to be
discounted. Your discount structure should not include a target element if the
promotion is for orders or shipping; only item discounts include target as part
of the discount-structure.
Discount-Structure element
The discount-structure element has the following attributes:
calculator-type: A calculator service configured in the pricing engine. For all Oracle CX Commerce promotions, the value forcalculator-typeisstandard.discount-type: The calculators use this value to determine how to calculate an adjustment. Valid values are:percentOff,amountOff,free, andfixedPrice.adjuster: This optional attribute specifies the price adjustment to make for this discount. For example, the following discount structure element specifies that the promotion should discount the target by 50%:
<discount-structure calculator-type="standard" discount-type="percentOff" adjuster="50"></discount-structure>Attribute element
The attribute element allows you to add generic name/value pairs to
parent tags, similar to the process used to extend a Core Commerce repository. During PMDL
parsing, the attributes and their values are placed in an attribute Map.
Iterator element
An iterator sorts a collection of items, then evaluate each item
against one or more sub-expressions. It returns those items that match the sub-expressions.
The iterator element allows you to create custom iterators. Your new
iterator element must include a name attribute that is unique
across the PMDL.
An iterator element can have the following attributes and
sub-elements:
nameattribute (required)sort-byattribute (required)sort-orderattribute (required)collection-name(required)element-name(required)element-quantity-property
Quantifier element
Quantifiers are evaluation beans that evaluate a collection of items against one or
more sub-expressions. It returns true or false, depending on
the quantity of items that match the sub-expressions.
The quantifier element allows you to create custom quantifiers. Your
new quantifier element must include a name attribute that is unique across the
PMDL.
A quantifier element can have the following attributes and
sub-elements:
nameattribute (required)numberattributecollection-name(required)element-name(required)element-quantity-property
Operator element
Operators return true or false based on the
Boolean results from their sub-expressions.
The operator element allows you to create custom operators. Your
new operator element must include a name attribute that is unique across the
PMDL.
An operator element can specify any number of attribute
sub-elements and operates on at least one comparator, operator or quantifier.
Comparator element
Comparators return true or false depending on the
values of their sub-expressions.
The comparator element allows you to create custom comparators.
Your new comparator element must include a name attribute that
is unique across the PMDL. A comparator element can specify any number of
attribute sub-elements and must specify at least one value or array name.
Comparators evaluate using one or more sub-expressions. For example:
<comparator name="includes-any">Comparators can also compare two value elements, and custom comparators could
include any number of value or constant elements.
Value element
The value element returns the value of a property of the item the
promotion is evaluating. You must include the value element for Buy One Get One
promotions as follows:
<value>item.auxiliaryData.productRef.ancestorCategoryIds</value>Constant element
The constant element returns a constant value against which other
values can be compared. For example:
<constant>
<data-type>java.lang.String</data-type>
<string-value>xprod2147</string-value>
</constant>