Tutorials > Management Center > Create a new promotion type

< Previous | Next >


Create and registering the XSL template

In this lesson, you retrieve an XSL template for the new promotion type and learn about its structure. You then register it as a new promotion rule. The purpose of the XSL template is to transform the authoring promotion XML into the runtime promotion XML. This transformation takes place when a promotion based on this promotion type is activated in the Management Center.

The XSL template you need is provided for you at a link in the following procedure, so you do not need to create it from scratch for this tutorial. This new XSL template must be registered in the promotion configuration registry as a new promotion rule. This is a requirement before you can enable the new promotion type. For detailed information about XSL template functions, see Create a custom promotion type in the Management Center.


Procedure

  1. Create a new directory for the XSL template:

    1. Locate the WC_EAR/xml/config directory.

    2. Under the config folder, add two new folders to create the directory structure WC_EAR/xml/config/com.ibm.commerce.promotion-ext/template.

  2. Download the ProductLevelFreeGiftPurchaseConditionTemplate.xsl file.

  3. Copy the file into the template folder.

  4. Open the file with any XML or text editor, and then observe the main characteristics of the ProductLevelFreeGiftPurchaseConditionTemplate.xsl template:

    • The main section of the XSL file is <xsl:template name="PurchaseConditionTemplate" match="/">, which defines the transformation template for the purchase condition. In the first lesson in this tutorial, you learned that the purchase condition is the key element of the new promotion type.

    • Under PurchaseConditionTemplate, there are two main elements that can be mapped to the corresponding runtime promotion XML elements, <Pattern> and <Distribution>.

    • There are some variables in the template, which are used to transform the authoring promotion XML data into the runtime promotion XML data. They use the element <xsl:value-of> to retrieve the data, for example:

      <LowerBound><xsl:value-of 
      select="PromotionData/Elements/PurchaseCondition/Data/BaseItemTotalPrice" /></LowerBound>
      

    • For some elements, there may be multiple instances; the template uses the <xsl:for-each> element to retrieve the multiple values for the elements, for example:

      <xsl:for-each select="PromotionData/Elements/PurchaseCondition/IncludeCatalogEntryIdentifier">
      

  5. Register the XSL template.

    To do this, you create a file that tells the promotion service which XSL templates to use to transform the authoring promotion XML to the runtime promotion XML. You reference the customized XSL template in this file.

    1. In the folder WC_EAR/xml/config/com.ibm.commerce.promotion-ext, create a new file called com.ibm.commerce.promotion.facade.server.config.PromotionComponentConfigurationImpl.xml.

    2. Open the file with an XML or text editor and copy the following code into it:

      <promotionComponentRegistry impl="com.ibm.commerce.promotion.facade.server.config.PromotionComponentRegistry"
               promotionTemplateRelativePath="template">
              
      <promotionTypeConfiguration name="ProductLevelFreeGift" >
                       <param key="purchaseConditionTemplate" value="ProductLevelFreeGiftPurchaseConditionTemplate.xsl"/>
                      
      <param key="basePromotionTemplate" value="DefaultBasePromotionTemplate.xsl"/>
                      
      <param key="customConditionTemplate" value="DefaultCustomConditionsTemplate.xsl"/>
                      
      <param key="targetingConditionTemplate" value="DefaultTargetingConditionTemplate.xsl"/>
                      
      <param key="promotionGroup" value="ProductLevelPromotion"/>
                      
      <param key="calculationCodeDisplayLevel" value="0"/>
              
      </promotionTypeConfiguration>
      
      </promotionComponentRegistry>
      

      In the previous code example, observe the fourth line, which appears in boldface text. This line registers the new customized XSL template. The other templates referenced here are the default XSL templates. You can use these default template versions because you did not customize these parts of your promotion. Also, observe the last two parameters, promotionGroup and calculationCodeDisplayLevel.

      • promotionGroup: This parameter references the promotion group that the promotion type belongs to, that is, order-level, product-level, or shipping.

      • calculationCodeDisplayLevel: This parameter defines what customers see on the storefront regarding the promotion price adjustment. The value 0 (order item display level) means a customer sees the adjustment broken down for each individual item in their order. The value 1 (order display level) means the customer sees the adjustment for the whole order in a summary.

    3. Save and close the file.

    4. Restart the WebSphere Commerce test server to load the new XSL template and XSL registry.

You have now completed all the steps to create a new promotion type. In the remaining lessons, we will verify the new promotion type in the Management Center and on the storefront.

< Previous | Next >


+

Search Tips   |   Advanced Search