The PMDL that describes Core Commerce promotions discount rules is relatively simple. The PMDL DTD is located in the DCS module at /atg/dtds/pmdl/pmdl_1.0.dtd
. The DTD defines the following to use in your PCML rules:
Iterators such as
next
,up-to-and-including
andevery
Quantifiers that are used in WHEN conditions, such as
at-least
,at-most
,exactly
andall
Operators such as
and
,or
andnot
Comparators such as
starts-with
,ends-with
,contains
,greater-than
,less-than
andequals
, which compare values and/or arrays.Operations such as
union
andanded-union
Value types such as
constant
ornull
Array types such as
constant
orvalue
The PMDL DTD contains the following elements:
Pricing-Model Element
Offer Element
Every pricing-model
element requires one offer
element. The offer
includes one or more discount-structure
elements, which contain detailed information about the discount and its target. The offer
is evaluated by the evaluateTarget
method.
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
element requires one qualifier
element. The element is the root tag for the condition part of the promotion.
Target Element
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
. The target
specifies the rule for selecting the items to be discounted.
Discount-Structure Element
The discount-structure
element has the following attributes:
calculator-type
—A calculator service configured in the pricing engine’scalculatorTypeCalculators
map.discount-type
—The calculators use this value to determine how to calculate an adjustment. Examples includepercentOff
andfixedPrice
.adjuster
—This optional attribute specifies the price adjustment to make for this discount.
A discount-structure
element can also include discount-detail
elements.
Discount-Detail Element
This element is optional, and is used for complex discount types. For example, in a tiered discount, each band is represented by a discount-detail
element. In this case, a discount-detail
element would include one or more attribute elements that describe the band. For example, the XML representation of a band where buying 5 or more items gives the customer 10% off might look like the following:
<attribute name="band" value="5"/>
<attribute name="adjuster" value="10"/>
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
Iterators are evaluation beans that sort 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:
name
attribute—Requiredsort-by
attribute—Requiredsort-order
attribute—Requiredcollection-name
—Requiredelement-name
—Requiredelement-quantity
-property—Optional
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:
name
attribute—Requirednumber
attribute—Optionalcollection-name
—Requiredelement-name
—Requiredelement-quantity-property
—Optional
Operator Element
Operators are evaluation beans that 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 are evaluation beans that 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="isoneof">
<value>item.auxiliaryData.productId</value>
<constant>
<data-type>java.lang.String</data-type>
<string-value>xprod2147</string-value>
<string-value>xprod2163</string-value>
</constant>
</comparator>
Comparators can also compare two value
elements, and custom comparators could include any number of value
or constant
elements.
Value and String-Value Elements
The value
element returns the value of a property of the commerce item being evaluated. For example:
<value>item.auxiliaryData.productId</value>
To represent strings, use a string-value
element. For example:
<string-value>ManufacturerA</string-value>
To represent a comma-separated list of strings, use multiple string-value
elements. For example, to represent “ManufacturerA, ManufacturerB” use the following:
<string-value>ManufacturerA</string-value>
<string-value>ManufacturerB</string-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>
Group-Iterator Element
The group-iterator
element, which is similar to the iterator
element, returns a group of items for discounts. It uses the every-group
and up-to-and-including-group
iterators.
When creating a new group-iterator
element you must include a name
attribute that is unique across the PMDL.
The following is an example of a group-iterator
:
<group-iterator name="every-group"> <anded-union> <iterator name="next" number="1" sort-by="priceInfo.listPrice" sort-order="descending"> <collection-name>items</collection-name> <element-name>item</element-name> <aggregator name="quantity" operation="total"/> <equals><value>item.catalogRefId</value> <constant> <data-type>java.lang.String</data-type> <string-value>sku40105</string-value> </constant> </equals> </iterator> <iterator name="next" number="1" sort-by="priceInfo.listPrice" sort-order="descending"> <collection-name>items</collection-name> <element-name>item</element-name> <aggregator name="quantity" operation="total"/> <equals><value>item.catalogRefId</value> <constant> <data-type>java.lang.String</data-type> <string-value>sku40109</string-value> </constant> </equals> </iterator> </anded-union> </group-iterator>