Extraction du code XML d'exécution pour un type de promotion

Vous pouvez extraire de votre base de données le code XML d'exécution d'une promotion active dans votre magasin. Si vous créez un type de promotion personnalisé, vous pouvez utiliser le XML d'exécution d'un type de promotion existant comme modèle de conception du XML de votre nouveau type.

Pourquoi et quand exécuter cette tâche

Les exemples de XML d'exécution de promotion peuvent vous servir de point de départ pour créer des types de promotion personnalisés pour votre magasin. Utilisez le XML d'exécution de promotion pour un type de promotion similaire au type de promotion personnalisé que vous créez. Vous pouvez extraire le XML d'exécution d'une promotion existante dans votre base de données. Ce XML est stocké dans la colonne XMLPARAM de la table de base de données PX_PROMOTION. Prenez soin de sélectionner une promotion déjà activée. Tant qu'aucune promotion créée dans le Centre de gestion n'est activée, seul le XML de marque de réservation est stocké dans la colonne XMLPARAM ; ce XML s'affiche comme suit : PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.AlwaysFalsePurchaseCondition".

Pour extraire le XML d'exécution d'un type de promotion par défaut, effectuez les étapes suivantes :

Procédure

  1. Open the Promotions tool.
  2. Créez une promotion basée sur un type de promotion existant. Sélectionnez un type de promotion similaire au type de promotion personnalisé que vous souhaitez créer.
    Pour plus d'informations sur la création d'une promotion, voir Création de promotions
  3. Activez la nouvelle promotion. L'activation de la promotion génère le code XML d'exécution de cette promotion. Pour plus d'informations sur l'activation d'une promotion, voir Activation ou désactivation de promotions
  4. Dans la vue Explorateur, cliquez sur le répertoire Promotions. La liste des promotions disponibles s'affiche dans la zone de travail principale. Dans la table de la vue de liste Promotions, configurez les colonnes pour afficher la colonne ID unique. Enregistrez l'ID unique de la promotion que vous avez créée.
    Pour plus d'informations sur l'affichage des colonnes masquées, voir Utilisation des vues de table
  5. Ouvrez une connexion de base de données.
  6. Exécutez la requête suivante pour extraire le code XML d'exécution de votre promotion :
    Select XMLPARAM from PX_PROMOTION where PX_PROMOTION_ID=yourPromotionUniqueId

    yourPromotionUniqueId correspond à l'ID que vous avez enregistré à l'étape 3. Le résultat de votre requête renvoie le code XML d'exécution de votre promotion. Par exemple, l'exemple de code suivant représente le XML d'exécution d'une promotion qui offre un cadeau pour les commandes supérieures à 2 000 USD :

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!-- This promotion does the following: Purchase over $2000 USD, receive free gift. -->
    
    <Promotion impl="com.ibm.commerce.marketing.promotion.DefaultPromotion">
    
      <!-- this identifies the promotion -->
      
      <PromotionKey>
        
        <-- Name of the promotion -->
        
        <PromotionName>Free gift with selected orders</PromotionName>
        
        <!-- The store that owns this promotion. Store key is defined as the combination of the 
             DN of the organization that owns this store and a store name --> 
        <StoreKey>
          <DN>ou=elite,o=seller organization,o=root organization</DN>
          <Identifier>Elite</Identifier>
        </StoreKey>
        
        <!-- Versions of a promotion. Statistics are associated with the
             version number,promotions with the same promotion key and version 
             number but different revision are considered different revisions of
             the same promotion.  Promotions with the same key but different 
             version numbers are considered distinct promotions. -->
        
        <Version>1</Version>
        <Revision>3</Revision>
      </PromotionKey>
      
      <!-- Promotions are group by groups, and groups are scoped by store, 
           refer to promotion organization for details on what a group is, its role 
           and the default groups -->
      
      <PromotionGroupKey>
        <GroupName>OrderLevelPromotion</GroupName>
        <StoreKey>
          <DN>ou=elite,o=seller organization,o=root organization</DN>
          <Identifier>Elite</Identifier>
        </StoreKey>
      </PromotionGroupKey>
      
      <!-- Various descriptions of the promotion -->
      
      <TypedNLDescription impl="com.ibm.commerce.marketing.promotion.TypedNLDescription">
        <DefaultLocale>en_US</DefaultLocale>
        <Description locale="en_US" type="admin">Order Discount - Free Gift with orders over $2000 USD</Description>
        <Description locale="en_US" type="long">Spend over $2000 USD and get a free passenger vehicle battery.</Description>
        <Description locale="en_US" type="short">Spend over $2000 USD and get a free gift!</Description>
      </TypedNLDescription>
      
      <!-- Priority of the promotion the higher the more important
      
      <Priority>250</Priority>
      
      <-- Exclusiveness of the promotion. Possible values are:  
          0: not exclusive at all 
          1: exclusive at the group level 
          2: exclusive at a global level 
          3: a backward compatibility mode that mimics the combinability 
             of order level promotions with product level promotions in 
             previous releases 
          4: This promotion can be stacked on top of other promotions in the same promotion group
      -->
          
      <Exclusive>0</Exclusive>
      
      <!-- For future use, always empty for now -->
      
      <ExemptPolicyList/>
      
      <!-- For future use, always empty for now -->
      
      <ExplicitlyAppliedPolicyList/>
      
      <!-- Status of the promotion: 
           0: inactive
           1: active
           2: deleted
           3: suspended 
           4: obsolete
      -->
      
      <Status>1</Status>
      
      <!-- Audit trail, last update time and last person who updated the promotion -->
      <LastUpdate>18-06-2011 15:53:46</LastUpdate>
      <LastUpdateBy>
        <CustomerKey>
          <LogonId>wcsadmin</LogonId>
        </CustomerKey>
      </LastUpdateBy>
      
      <!-- How many times this promotion can be applied to the current order, 
           possible values are:  
           -1:              unlimited
           positive number: the limit 
      -->
      
      <PerOrderLimit>-1</PerOrderLimit>
      
      <!--How many times this promotion can be applied to a shopper, 
          possible values are:  
          -1:              unlimited,
          positive number: the limit 
      
          This value is only valid for a registered shopper, for none registered 
          shoppers there is no way to control how many times a shopper can redeem a 
          promotion. 
      -->
      
      <PerShopperLimit>1</PerShopperLimit>
      
      <!-- How many times this promotion can be redeemed overall.
           Possible values are:
           -1:              unlimited,
           positive number: the limit 
      -->
      <ApplicationLimit>-1</ApplicationLimit>
      
      <TargetSales>0.00000</TargetSales>
      <CorrespondingRBDTypeName>OrderLevelFreeGift</CorrespondingRBDTypeName>
      
      <!-- Schedule information of this promotion -->
      
      <Schedule impl="com.ibm.commerce.marketing.promotion.schedule.PromotionSchedule">
        <DateRange impl="com.ibm.commerce.marketing.promotion.schedule.DateRangeSchedule">
          <Start inclusive="true">01-01-2004 12:00:00</Start>
          <End inclusive="true">31-12-9999 12:00:00</End>
        </DateRange>
        <TimeWithinADay impl="com.ibm.commerce.marketing.promotion.schedule.TimeRangeWithinADaySchedule">
          <Start inclusive="true">00:00:00</Start>
          <End inclusive="true">23:59:59</End>
        </TimeWithinADay>
        <Week impl="com.ibm.commerce.marketing.promotion.schedule.WeekDaySchedule">
          <WeekDay>SUNDAY</WeekDay>
          <WeekDay>MONDAY</WeekDay>
          <WeekDay>TUESDAY</WeekDay>
          <WeekDay>WEDNESDAY</WeekDay>
          <WeekDay>THURSDAY</WeekDay>
          <WeekDay>FRIDAY</WeekDay>
          <WeekDay>SATURDAY</WeekDay>
        </Week>
      </Schedule>
      
      <!-- Type of promotion:
          0: targeted
          1: private, that is, a coupon promotion 
      -->
      <PromotionType>0</PromotionType>
      
      <!-- Whether a code is required to redeem this promotion. -->
      
      <PromotionCodeRequired>false</PromotionCodeRequired>
      
      <!-- When a promotion code is entered, should the target condition be checked -->
      
      <SkipTargetingConditionOnProperPromotionCodeEntered>false</SkipTargetingConditionOnProperPromotionCodeEntered>
      
      <!-- Check the target condition or not -->
      
      <CheckTargetingConditionAtRuntime>true</CheckTargetingConditionAtRuntime>
      
      <!-- Do not change this element -->
      
      <PromotionCodeCondition impl="com.ibm.commerce.marketing.promotion.condition.PromotionCodeCondition"/>
      
      <!-- Targeting condition --> 
      
      <Targeting impl="com.ibm.commerce.marketing.promotion.condition.TargetingCondition">
      </Targeting>
      
      <!-- Custom condition for the promotion can be added here -->
      
      <CustomConditions/>
      
      <!-- This is core of a promotion definition -->
      
      <PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.PurchaseCondition">
        
        <!-- Matches the pattern targeted by the current promotion: the following 
             pattern matches the entire order, for details refer to the promotion 
             purchase condition model document 
        -->
        
        <Pattern impl="com.ibm.commerce.marketing.promotion.condition.Pattern">
          
          <!-- A pattern is made up of multiple constraint, each specifying a 
               list of items that make up part of the pattern. There must be no 
               cross-sections between constraints 
          -->
          
          <UniqueConstraints>false</UniqueConstraints>
          <Constraint impl="com.ibm.commerce.marketing.promotion.condition.Constraint">
            
            <!-- Quantity requirement of this constraint -->
            
            <WeightedRange impl="com.ibm.commerce.marketing.promotion.condition.WeightedRange">
              
              <!-- minimum number of item is 1 -->
              
              <LowerBound>1</LowerBound>
              
              <!--  Maximum number of item is not limited  -->
              
              <UpperBound>-1</UpperBound>
              
              <-- Match as many as items that satisfy the criteria defined in the filter chain next
              
              <Weight>1</Weight>
            </WeightedRange>
            
            <!-- Selection criteria -->    
            
            <FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
              
              <!-- Multiple filters can be specified, the are applied in a contiguous fashion, 
                   that is, connected using a logical "and". The dummy filter returns anything 
                   passed to it, it effectively selects anything 
              -->
              
              <Filter impl="com.ibm.commerce.marketing.promotion.condition.DummyFilter"/>
            </FilterChain>
            
            <!-- The combination of the quantity requirement and the filter chain would return 
                 everything present in the shopcart as one big matched pattern 
            -->   
          </Constraint>
        </Pattern>
        
        <!-- Once pattern is matched, rewards are assigned, for details refer to the 
             purchase condition model document 
        -->
        
        <Distribution impl="com.ibm.commerce.marketing.promotion.reward.Distribution">
          
          <!-- A volume based distribution on the spending total is performed, 
               spending total is measure in USD -->
          
          <Type>Volume</Type>
          <Base>Cost</Base>
          <Currency>USD</Currency>
          
          <!-- First range 2000 <= spending -->
          
          <Range impl="com.ibm.commerce.marketing.promotion.reward.DistributionRange">
            <UpperBound>-1</UpperBound>
            <LowerBound>2000</LowerBound>
            <UpperBoundIncluded>false</UpperBoundIncluded>
            <LowerBoundIncluded>true</LowerBoundIncluded>
            
            
            <RewardChoice>
                
                <!-- This reward, if the spending total of ALL matched patterns falls into the range of over 2000 -->
                
              <Reward impl="com.ibm.commerce.marketing.promotion.reward.DefaultReward">
                <AdjustmentFunction impl="com.ibm.commerce.marketing.promotion.reward.AdjustmentFunction">
                  
                  <!--  Reward can be associated with a sub set of the items that make up the pattern,
                        the input of this filter chain will be one matched pattern, and a sub set of 
                        items that make up that pattern is returned and adjustments are associated with 
                        the returned items also known as affected items
                  -->
                  <FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
                    <Filter impl="com.ibm.commerce.marketing.promotion.condition.DummyFilter"/>
                  </FilterChain>
                  
                  <!--  the adjustment  -->
                  <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.DefaultChoiceOfFreeGiftAdjustment">
                    <RewardSpecification impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftSpecification">
                      <MaxQuantity>1</MaxQuantity>
                      <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem"> 
                        <Quantity>1</Quantity>
                        <CatalogEntryKey>
                          <SKU>A0000736</SKU>
                          <DN>ou=elite,o=seller organization,o=root organization</DN>
                        </CatalogEntryKey>
                      </GiftItem>
                    </RewardSpecification>
                    <RewardChoice impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftChoice">
                      <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem">
                        <Quantity>1</Quantity>
                        <CatalogEntryKey>
                          <SKU>A0000736</SKU>
                          <DN>ou=elite,o=seller organization,o=root organization</DN>
                        </CatalogEntryKey>
                      </GiftItem>
                    </RewardChoice>
                    
                    <!-- This adjustment is applied to the entire order, 
                         possible values are: (case insentitive)
                         wholeOrder:  The entire order, that is, $15 dollars off 
                                      an entire order
                         AllAffectedItems: Affected items returned by the filter 
                                       chain defined above, that is, $15  dollars 
                                       off all of the affected items as a whole.
                         IndividualAffectedItems: Adjustments are applied to 
                                       affected items individually, that is, $15 
                                       dollars off each and every affected item.
                    -->
                    <AdjustmentType>AllAffectedItems</AdjustmentType>
                  </Adjustment>
                </AdjustmentFunction>
                <RewardPolicy>ALL</RewardPolicy>
              </Reward>
            </RewardChoice>
          </Range>
          <PatternFilter impl="com.ibm.commerce.marketing.promotion.condition.DummyPatternFilter"/>
        </Distribution>
      </PurchaseCondition>
    </Promotion>
  7. Copiez les données de votre résultat et collez-les dans un document. Sauvegardez ce document au format XML. Vous pouvez le prévisualiser dans un navigateur Web pour une meilleure lisibilité.