Migrate > Take the first steps after WebSphere Commerce migration > Migrating promotions



Sample OrderLevelPercentOff XSL template

The OrderLevelPercentOff XSL template transforms OrderLevelPercentOff promotions to an intermediate XML format. This sample XSL template only extracts the information from a runtime promotion XML that it needs to save to the PX_PROMOAUTH, PX_DESCRIPTION, PX_PROMOCD, PX_ELEMENT, and PX_ELEMENTNVP tables.


Sample

The following sample XML snippet is an example of an XSL template used to transform promotions to the Management Center data model using the promotion migration utility. Use this sample as a guideline when creating custom XML templates for the custom promotion types. In this example, this XSL template transforms promotions of type OrderLevelPercentOff to the intermediate XML document used to populate the database tables. The migration utility selects the information to save to the database tables from the intermediate XML document based on certain tag names. Therefore, when defining the XSL template, use the exact predefined tag names that are highlighted later in this topic; otherwise the information will not be saved to the corresponding database table from the transformed XML document. The tree structure of the XSL template is used to determine the parent-child relationship between the elements. Additional information corresponding to the callout numbers is provided below the example.

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template name="PromotionMigrationTemplate" match="/"> 
  
<!-- handle default promotion rule --> 
  
<PromotionMigrationData> 
     
<px_promoauth>   1  
        
<promotionType> 
           
<xsl:value-of select="Promotion/CorrespondingRBDTypeName" /> 
        
</promotionType> 
        
<dailyStartTime> 
           
<xsl:value-of select="Promotion/Schedule/TimeWithinADay/Start" /> 
        
</dailyStartTime> 
        
<dailyEndTime> 
           
<xsl:value-of select="Promotion/Schedule/TimeWithinADay/End" /> 
        
</dailyEndTime> 
        
<xsl:for-each select="Promotion/Schedule/Week/WeekDay"> 
           
<xsl:choose>     
              
<xsl:when test=".='SUNDAY'">         
                 
<weekday_sun>1</weekday_sun>     
              
</xsl:when>     
              
<xsl:when test=".='MONDAY'">         
                 
<weekday_mon>1</weekday_mon>     
              
</xsl:when>     
              
<xsl:when test=".='TUESDAY'">         
                 
<weekday_tue>1</weekday_tue>     
              
</xsl:when>     
              
<xsl:when test=".='WEDNESDAY'">         
                 
<weekday_wed>1</weekday_wed>     
              
</xsl:when>     
              
<xsl:when test=".='THURSDAY'">         
                 
<weekday_thu>1</weekday_thu>     
              
</xsl:when>     
              
<xsl:when test=".='FRIDAY'">         
                 
<weekday_fri>1</weekday_fri>     
              
</xsl:when>     
              
<xsl:when test=".='SATURDAY'">         
                 
<weekday_sat>1</weekday_sat>     
              
</xsl:when> 
           
</xsl:choose> 
        
</xsl:for-each> 
        
<comments> 
           
<xsl:value-of select="Promotion/TypedNLDescription/Description[@type='admin']" /> 
        
</comments> 
     
</px_promoauth> 
     
<xsl:choose>     
        
<xsl:when test="Promotion/PromotionCodeRequired='true'">             
           
<PromotionCodeCue>  2                  
              
<xsl:value-of select="Promotion/PromotionCodeCue" />             
           
</PromotionCodeCue>     
        
</xsl:when> 
     
</xsl:choose> 
     
<xsl:for-each select="Promotion/TypedNLDescription/Description"> 
        
<px_description>  3 
           
<language>     
              
<xsl:value-of select="@locale" /> 
           
</language> 
           
<type>     
              
<xsl:value-of select="@type" /> 
           
</type> 
           
<description>     
              
<xsl:value-of select="." /> 
           
</description> 
        
</px_description> 
     
</xsl:for-each> 
     
<!-- Px_element --> 
     
<elements>  4 
        
<element> 
           
<type>TargetingCondition</type> 
           
<subType>TargetingCondition</subType> 
           
<xsl:for-each select="Promotion/Targeting/TargetedProfile/CustomerProfileKey">     
              
<element>         
                 
<type>IncludeMemberGroupIdentifier</type>         
                 
<subType>Identifier_MemberGroup</subType>         
                 
<Data>             
                    
<OwnerDN>                 
                       
<xsl:value-of select="OwnerDN" />             
                    
</OwnerDN>             
                    
<ProfileName>                 
                       
<xsl:value-of select="ProfileName" />             
                    
</ProfileName>         
                 
</Data>     
              
</element> 
           
</xsl:for-each>
           
<xsl:for-each select="Promotion/Targeting/ExcludedProfile/CustomerProfileKey"> 
              
<element>         
                 
<type>ExcludeMemberGroupIdentifier</type>         
                 
<subType>Identifier_MemberGroup</subType>         
                 
<Data>             
                    
<OwnerDN>                 
                       
<xsl:value-of select="OwnerDN" />             
                    
</OwnerDN>             
                    
<ProfileName>                 
                       
<xsl:value-of select="ProfileName" />             
                    
</ProfileName>         
                 
</Data>     
              
</element>
           
</xsl:for-each> 
        
</element> 
        
<element> 
           
<type>PurchaseCondition</type> 
           
<subType>OrderLevelPercentDiscountPurchaseCondition</subType> 
           
<Data>     
              
<Currency>         
                 
<xsl:value-of select="Promotion/PurchaseCondition/Distribution/Currency" />     
              
</Currency> 
           
</Data> 
           
<xsl:for-each select="Promotion/PurchaseCondition/Distribution/Range">     
              
<element>         
                 
<type>DiscountRange</type>         
                 
<subType>OrderLevelPercentOffDiscountRange</subType> 
                 
<Data>         
                    
<LowerBound>             
                       
<xsl:value-of select="LowerBound" />         
                    
</LowerBound>         
                    
<Percentage>             
                       
<xsl:value-of select="RewardChoice/Reward/AdjustmentFunction/Adjustment/Percentage" />
                    
</Percentage>     
                 
</Data>     
              
</element> 
           
</xsl:for-each> 
        
</element> 
     
</elements>  
  
</PromotionMigrationData> 
</xsl:template> 
</xsl:transform>


PX_PROMOAUTH node

 1 

This node extracts the data saved to the PX_PROMOAUTH table. This includes the promotion type, dailyStartTime, dailyEndTime, days of the week a promotion is available, and the comments field. The administrative name of the promotion is copied directly from the PX_PROMOTION.NAME column to the PX_PROMOAUTH.ADMINSTVENAME column. The structure under the <px_promoauth> node is static and common for all promotion rules. In this sample, for the PX_PROMOAUTH node, the predefined tag names for migration are highlighted:

<px_promoauth>
   <promotionType>
     
<xsl:value-of select="Promotion/CorrespondingRBDTypeName" />
   </promotionType>
   <dailyStartTime>
     
<xsl:value-of select="Promotion/Schedule/TimeWithinADay/Start" />
   </dailyStartTime>
   <dailyEndTime>
     
<xsl:value-of select="Promotion/Schedule/TimeWithinADay/End" />
   </dailyEndTime>
  
<xsl:for-each select="Promotion/Schedule/Week/WeekDay">
     
<xsl:choose>
        
<xsl:when test=".='SUNDAY'">
            <weekday_sun>1</weekday_sun>
        
</xsl:when>
        
<xsl:when test=".='MONDAY'">
            <weekday_mon>1</weekday_mon>
        
</xsl:when>
        
<xsl:when test=".='TUESDAY'">
            <weekday_tue>1</weekday_tue>
        
</xsl:when>
        
<xsl:when test=".='WEDNESDAY'">
            <weekday_wed>1</weekday_wed>
        
</xsl:when>
        
<xsl:when test=".='THURSDAY'">
            <weekday_thu>1</weekday_thu>
        
</xsl:when>
        
<xsl:when test=".='FRIDAY'">
            <weekday_fri>1</weekday_fri>
        
</xsl:when>
        
<xsl:when test=".='SATURDAY'">
            <weekday_sat>1</weekday_sat>
        
</xsl:when>
     
</xsl:choose>
  
</xsl:for-each>
   <comments>
     
<xsl:value-of select="Promotion/TypedNLDescription/Description[@type='admin']" />
   </comments>
</px_promoauth>


PromotionCodeCue node

 2 

This node extracts the data saved to the PX_PROMOCD table. The <PromotionCodeCue> tag name must be used, as the migration utility uses this tag name to extract the code from the transformed XML document. In this sample, for the PromotionCodeCue node, the pre-defined tag names for migration are highlighted below.

<PromotionCodeCue>
  
<xsl:value-of select="Promotion/PromotionCodeCue" />
</PromotionCodeCue> 


PX_DESCRIPTION node

 3 

This node extracts the data saved to the PX_DESCRIPTION table. In this sample, for the PX_DESCRIPTION node, the pre-defined tag names for migration are highlighted below.

<px_description>
   <language>     
     
<xsl:value-of select="@locale" /> 
   </language> 
   <type>     
     
<xsl:value-of select="@type" /> 
   </type> 
   <description>     
     
<xsl:value-of select="." /> 
   </description> 
</px_description> 


PX_ELEMENT and PX_ELEMENTNVP nodes

 4 

The migration utility looks for the elements tag as the start of element data. The top three elements, namely Targeting Condition, Purchase Condition, and Custom Conditions, are defined using the element tag.

The value of the type node for each element defines the promotion concept used in the runtime promotion XML. For example, the element type "PurchaseCondition" is similar to the "PurchaseCondition" node in the runtime promotion XML. And the type "DiscountRange" is similar to the "DistributionRange" node in the runtime promotion XML. The value of the subType node for each element is used by the Management Center framework to identify a specific user interface element that handles the input from business user. The values of the type and subType nodes are saved to the TYPE and SUBTYPE columns of the PX_ELEMENT table respectively. See How promotion data is stored and managed for sample PX_ELEMENT table content.

The Data node under an element is used to define the name-value pairs for that element. The nodes under the Data node are used to extract information to save to the PX_ELEMENTNVP table. The name of these nodes is saved to the NAME column and their value is saved to the corresponding VALUE column. For the predefined promotion elements, the migration utility determines the ID based on the values of the nodes defined under the Data node. For example, for the IncludeMemberGroupIdentifier predefined element, the ID value is determined using the values of the OwnerDN and ProfileName nodes. The name of these predefined elements is saved as ID in the NAME column of the PX_ELEMENTNVP table, and the value which is the corresponding ID value determined, is saved to the VALUE column. In this sample, for the PX_ELEMENT and PX_ELEMENTNVP nodes, the predefined tag names and values for migration are highlighted below.

<elements>
   <element>
      <type>TargetingCondition</type>
      <subType>TargetingCondition</subType>
     
<xsl:for-each    select="Promotion/Targeting/TargetedProfile/CustomerProfileKey">
         <element>
            <type>IncludeMemberGroupIdentifier</type>
            <subType>Identifier_MemberGroup</subType>
            <Data>
               <OwnerDN><xsl:value-of select="OwnerDN" /></OwnerDN>
               <ProfileName>
                 
<xsl:value-of select="ProfileName" />
               </ProfileName>
            </Data>
         </element>
     
</xsl:for-each>
     
<xsl:for-each select="Promotion/Targeting/ExcludedProfile/CustomerProfileKey">
         <element>
            <type>ExcludeMemberGroupIdentifier</type>
            <subType>Identifier_MemberGroup</subType>
            <Data>
               <OwnerDN><xsl:value-of select="OwnerDN" /></OwnerDN>
               <ProfileName><xsl:value-of select="ProfileName" /></ProfileName>
            </Data>
         </element>
     
</xsl:for-each>
   </element>
   <element>
      <type>PurchaseCondition</type>
      <subType>OrderLevelPercentDiscountPurchaseCondition</subType>
      <Data>
        
<Currency>
           
<xsl:value-of select="Promotion/PurchaseCondition/Distribution/Currency" />
        
</Currency>
      </Data>
     
<xsl:for-each select="Promotion/PurchaseCondition/Distribution/Range">
         <element>
            <type>DiscountRange</type>
            <subType>OrderLevelPercentOffDiscountRange</subType>
            <Data>
              
<LowerBound><xsl:value-of select="LowerBound" /></LowerBound>
              
<Percentage>
                 
<xsl:value-of 
                     select="RewardChoice/Reward/AdjustmentFunction/Adjustment/Percentage" />
              
</Percentage>
            </Data>
         </element>
     
</xsl:for-each>
   </element>
</elements>


Related tasks

Migrate promotions

Migrate promotions built on default promotion types: complete migration

Migrate promotions: partial migration


+

Search Tips   |   Advanced Search