Creating the object template

In this lesson, you create an object template to define the object structure for the promotion. The object template contains all the objects that each promotion type requires. There is one object template for each promotion type defined in the Promotions tool to specify the unique properties of the promotion type.

About this task

Most promotion properties are common for all promotion types. For example, if you compare the user interface for certain properties, such as the redemption limit and the promotion schedule, they typically look the same from one promotion type to the next. On the other hand, the properties of the purchase and reward conditions vary, depending on:
  • Whether the promotion is an order-level, catalog-entry-level or category-level promotion
  • Whether the discount is a fixed price, a percentage off, an amount off, or a free gift

The object template you are adding, extProductLevelFreeGiftTemplate, is a product level promotion, with a free gift reward.

Procedure

  1. Create a new folder for your template:
    1. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > xml > mycompany > promotion > objectDefinitions
    2. Right-click the objectDefinitions folder; then click New > Folder.
    3. In the Folder name field, type promotionTypes.
    4. Click Finish.
  2. Create a new file for the promotion template:
    1. Right-click the promotionTypes folder.
    2. Click New > File. Name the file ProductLevelFreeGiftTemplate.xml
    3. Click Finish to save the file.
      The file opens in the default XML editor.
  3. Copy and paste the following code into this definition file:
    
    <Definitions>
      <!--Object template for extended promotion type ProductLevelFreeGift. -->
      <ObjectTemplate definitionName="cmc/promotion/ExtProductLevelFreeGiftTemplate" description="${ExtPromotionResources.promotion_type_description_ProductLevelFreeGift}" displayName="${ExtPromotionResources.promotion_type_ProductLevelFreeGift}" templateType="ProductLevelFreeGift">
        <dependency localName="ExtPromotionResources" moduleName="cmc/promotion/ExtPromotionResources"/>
        <Xml name="template">
          <object objectType="ProductLevelFreeGiftPurchaseCondition"/>               
        </Xml>
      </ObjectTemplate>
    </Definitions>
    Notice the <object> elements defined in the template; the objectType value will be stored in the SUBTYPE column of the PX_ELEMENT table.
  4. Save and close the file.
  5. Add your new template to the promotion primary object definition.
    1. Expand LOBTools > WebContent > WEB-INF > src > xml > commerce > promotion > objectDefinitions
    2. Open the PromotionPrimaryObjectDefinition.xml file.
    3. Locate the section of the file where the other templates are declared, as shown in the following XML sample of a few templates:
      
      <ObjectTemplate baseDefinition="cmc/promotion/ProductLevelFixedCostDiscountTemplate"/>
      <ObjectTemplate baseDefinition="cmc/promotion/ProductLevelPerItemFixedCostDiscountTemplate"/>
      
    4. Insert the following code at the bottom of the list of templates:
      
      <!-- Customization: Promotion template of the new promotion type -->
      <ObjectTemplate baseDefinition="cmc/promotion/ExtProductLevelFreeGiftTemplate"/>
      This new promotion type will now display in the Promotion type list in the Promotions tool user interface.
    5. Save and close the file.

Results

In this lesson, you created the promotion user interface template. In the next lesson, you begin creating the customized widgets you need to support your promotion in the Management Center user interface.