Monday, February 15, 2016

Promotion based on Payment Method (ATG Oracle Commerce) ATG11.1

As you know The Promotion engine is powerful and it let you create advanced promotions with the Advanced Promotion template.

This template let you use the order and shipping properties to create the promotion.
However OOTB there is not a way to get a promotion based on the Payment Method, and the reason is due the order can have more than one, in order to make this happen you need to do some changes.

Let's say we want to create a promo to the users that use paypal, or the ones that use visa.

The steps to make this happen are here:

First you need to extend the atg.commerce.order.OrderImpl Class, which is very common when you are doing custom changes to the order definition, and create a method to return the paymentType used on the order.

Then that new class needs to be registered on /atg/commerce/order/OrderTools component as follows:

This is pretty standard order extend customization, however the trick is that the changes we are doing need to be deployed into BCC instance otherwise we won't be able to see the new property paymentType displayed on this advanced Promotion template.

And as you see there is no need to extend orderRepoistory.xml since this is a derived property.

If everything above is done correctly you will be able to see all the properties inside your OrderImpl bean displayed as options in the Advanced promotion template.

No need to change QualifierService or anything else to make this promo work.

All of this is documented at, here mention that you need to extend orderRepository.xml and the reason is becuase this is a generic example, since our payment type can be calculated we did not have to extend the orderRepository.

Friday, February 12, 2016

jvm arg to make StackTrace be smaller (java)

There is an easy way to make JVM to log smaller stack trace in most of the cases the stack trace have the most useful information in the very first few lines, so there is no need to print it all.
Also printing the complete stack trace will make bigger logs on you server.

Just need to add the following XX arg to your jvm:


The depth depends on you, I made it 5, but it can be what you want, the default is 1024.

And the results will be as the below image:

Here is the definition of this XX arg:

MaxJavaStackTraceDepthMax. no. of lines in the stack trace for Java exceptions (0 means all).
With Java > 1.6, value 0 really means 0. value -1 or any negative number must be specified to print all the stack (tested with 1.6.0_22, 1.7.0 on Windows).
With Java <= 1.5, value 0 means everything, JVM chokes on negative number (tested with 1.5.0_22 on Windows).

And you can find a list of all the XX args that can be added to jvm: