Customizing promotion organization

If the default promotion groups (order level, product level and shipping) do not meet your business needs, you can customize your promotion organization. Specifically, you can create custom groups that are different from the default groups so that promotions in the new groups are governed by different policies. This customization should occur during store setup. This process includes incorporating the new promotion groups in an invocation template, and associating policies to these new groups.

Before you begin

This scenario assumes that no customization exists to the persistence management of promotion groups, promotions, or policies.

Before customizing your promotion organization, you must determine whether the custom promotion group is available to all of your stores, or just a subset. You must also determine the name of the group, the policies that are associated with this group, and how to include this group in the existing promotion evaluation. The following steps detail only how to add more groups, attach policies to them, and use them at run time.

Procedure

  1. Create the policies that are assigned to this group. To create these policies, you must insert one or more entries into the PX_POLICY table. To help create your policies, consider using a default policy as a base to model your new policy. To find the default policies that are assigned to your store, open a database connection and run the following query:
    SELECT * FROM PX_POLICY WHERE STOREENT_ID=storeId;
    
    In the results from this query, the IMPLCLS column defines the name of the class that implements a policy. The XMLPARAM column contains the XML definition of a policy. The actual content of this XML fragment depends on the XML model for the policy implementation. A sample XML definition for a promotion policy resembles the following code:
    <PromotionPolicy impl="com.ibm.commerce.marketing.promotion.policy.RedemptionLimitEnforcementPolicy">
          <PromotionPolicyKey>
                <PolicyName>Unique Name for the policy</PolicyName>
                <StoreKey>
                      <DN>o=root organization</DN>
                      <Identifier>BlueStore 202</Identifier>
                </StoreKey>
          </PromotionPolicyKey>
          <Status>Active</Status>
    </PromotionPolicy>
    

    You can use an XML definition that returns from your query to help model your new policy. For more information about custom promotion policies, see Customizing promotion policies.

  2. Create the promotion group by inserting an entry for your group into the PX_GROUP table. To help create the entry for your group, you can use an existing group entry as a model for creating your group. To find the default groups that are assigned to your store, run the following query:
    SELECT * FROM PX_GROUP WHERE STOREENT_ID=storeId;
    In the results that are returned from your query, the XMLPARAM column contains the XML definition of the promotion groups. A sample XML definition for a promotion group resembles the following code:
    
    <PromotionGroup impl="com.ibm.commerce.marketing.promotion.group.PromotionGroup">
       <!-- Key is made up of a reference to the store that owns this group, and a string name -->
       <PromotionGroupKey>
          <GroupName>OrderLevelPromotion</GroupName>
          <StoreKey>
             <DN>o=root organization</DN>
             <Identifier>BlueStore 202</Identifier>
          </StoreKey>
       </PromotionGroupKey>
       <!-status is active -->
       <Status>active</Status>
    
       <!-- Associated policies -->
    
       <AssociatedPromotionPolicies>
          <PromotionPolicyKey>
             <PolicyName>New Policy One</PolicyName>
                <StoreKey>
                   <DN>o=root organization</DN>
                   <Identifier>BlueStore 202</Identifier>
                </StoreKey>
          </PromotionPolicyKey>
          <PromotionPolicyKey>
             <PolicyName>New Policy Two</PolicyName>
             <StoreKey>
                <DN>o=root organization</DN>
                <Identifier>BlueStore 202</Identifier>
             </StoreKey>
          </PromotionPolicyKey>
       </AssociatedPromotionPolicies>
    </PromotionGroup>
    
  3. Assign a policy to each promotion group you are creating. To assign a policy to a group, you must insert an entry into the PX_GRPPOLICY database table. This entry associates the PX_GROUP_ID of your promotion group with a specific policy, PX_POLICY_ID.
  4. Add your group to an invocation template by updating the promotion engine configuration XML. To add a group to an invocation template, you can edit an existing template, or duplicate a template and modify it to meet your requirements. If you want your new promotion group to be shared by all stores, you can add an entry for your group to the existing "All Promotions" template. If your group is specific to a store, you must duplicate a template and modify that template specific to your store.
    1. Go to the workspace_dir/WC/xml/PromotionEngineConfiguration directory.
    2. Open the WCSPromotionEngineConfig.xml file for editing.
    3. Locate the following code snippet. This snippet is the XML fragment that defines "All Promotions" template:
      
      <Template>
         <TemplateKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <Name>All Promotions</Name>
         </TemplateKey>
         <MonetaryValuePresence>
            <Price>true</Price>
            <ShippingCharge>false</ShippingCharge>
            <Tax>false</Tax>
            <ShippingTax>false</ShippingTax>
         </MonetaryValuePresence>
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>ProductLevelPromotion</GroupName>
         </PromotionGroupKey>
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>OrderLevelPromotion</GroupName>
         </PromotionGroupKey>
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>ShippingPromotion</GroupName>
         </PromotionGroupKey>
      </Template>
      
    4. Add your group to this template, or duplicate and modify the template to specify a store-specific group. Insert the entry for your group that is based on the order in which you want your promotions to be evaluated.
      For example, if you want promotions in the new group to be evaluated after promotions in the "ProductLevelPromotion" group, your template can resemble the following code snippet:
      
      <Template>
         <TemplateKey
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <Name>All Promotions</Name>
         </TemplateKey>
         <MonetaryValuePresence>
            <Price>true</Price>
            <ShippingCharge>false</ShippingCharge>
            <Tax>false</Tax>
            <ShippingTax>false</ShippingTax>
         </MonetaryValuePresence>
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>ProductLevelPromotion</GroupName>
         </PromotionGroupKey>
            
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>My New Group</GroupName>
         </PromotionGroupKey>
            
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>OrderLevelPromotion</GroupName>
         </PromotionGroupKey>
         <PromotionGroupKey>
            <StoreKey>
               <DN>o=root organization</DN>
               <Identifier>NullEntity</Identifier>
            </StoreKey>
            <GroupName>ShippingPromotion</GroupName>
         </PromotionGroupKey>
      </Template>
      
  5. Restart HCL Commerce. Since promotion groups, policies, and templates are all configuration information, and are cached, you must restart HCL Commerce before the changes take effect.