This discussion is archived
2 Replies Latest reply: Nov 5, 2012 11:56 AM by Nitin Khare RSS

Create component for target rules

Grando Journeyer
Currently Being Moderated
Hi all,

I have a requirement that is: I have to create a target that willl show one banner to user just when the user have a specific product in the shopping cart.
In BCC I couldn't find any rule for this, so I think that I need to create a custom component for this that returns the id's of the products in the shopping cart.

I am using ATG 10.1.1.

Some help?

  • 1. Re: Create component for target rules
    karthik chopperla Pro
    Currently Being Moderated
    Create a scenario and slot which says
    Event: " Add prod123 to cart " Action : " Populate slot123 with banner/image"

    Slot: Create media slot which holds images.

    Display the slot above the cart.

  • 2. Re: Create component for target rules
    Nitin Khare Expert
    Currently Being Moderated
    One approach can be by using a user defined property in profile to access the cart product Ids.

    You can always refer to user's current cart through /atg/commerce/ShoppingCart.current and since you need to access the product-Ids in the current cart for targeting rule so you can probably add a transient user defined property (let's say cartProductIds) in the profile which holds the product-Ids present in cart. So in userProfile.xml you would have:
    <item-descriptor name="user" ...>
      <property name="cartProductIds" property-type="com.mycompany.myapp.CartProductsPropertyDescriptor">
        <!-- if required pass additional attributes & values to your PropertyDescriptor implementaion -->
        <attribute name="attrib1" value="value1"/>
        <attribute name="attrib2" value="value2"/>
    CartProductsPropertyDescriptor is your custom PropertyDescriptor implementation which will be extending RepositoryPropertyDescriptor. Within which the getPropertyValue() method implementations can resolve to /atg/commerce/ShoppingCart.current to get the product-Ids. Having the property in profile will allow you to use it in the targeter and you can define the targeter RuleSet as:

    This Content ...
    To These People +People whose {  cartProductIds includes PRODUCT_IDs_YOU_WANT_TO_CHECK  }+
    At These Times ...
    Under These Conditions ...

    During targeter rule set's execution, profile's getPropertyValue() for "cartProductIds" property will actually invoke your CartProductsPropertyDescriptor's getPropertyValue() to return the product-Ids contained in shopping cart.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points