Thursday, August 31, 2017

Oracle Commerce - Create custom Derivation method


ATG Repositories have a feature called Derivations, that allow you to derive the value of a property based on other values.

This si a great way to help you design your repository definition and avoid duplicate data.

Here is an example of what you can do with an OOTB derivation:

Now, you can create your own Derivation method to do what you want.

Just do the following:
Create a Class that extends DerivationMethodImpl.

Override derivePropertyValue method

And in order to user it:
Now you can reuse this derivation to get the first element of a collection by just configuring the collection in the expression

There are several derivations already, just make sure that the one you want to implement is not already created OOTB https://docs.oracle.com/cd/E41069_01/Platform.11-0/ATGRepositoryGuide/html/s0612derivationmethods01.html

Thursday, May 4, 2017

Create Rest Service on Oracle Commerce ATG11.x

Oracle Commerce does provide with a rest service module that we can use to expose services. it is very easy to do, in this diagram is explained in high level how this can be done.
Let's say we are gonna create a Service that returns the review for a particular product.
We need to create a service component that will get the Reviews, that will be as follows:


Then, we need to register that new service as an Actor as follows:






Then register that new service chain url into ActorChainRestRegistry.properties, OOTB that already exist and holds the configuration for all the services.

Everything on how to do this is documented at http://docs.oracle.com/cd/E52191_03/Platform.11-1/ATGWSFrameGuide/html/s0502restmvcserviceflowexample01.html

And in the top of this you can add a new layer for cache the data using Cache Adapter.
That will looks like this.
In order to do implement the cache, you can use this page that is a very useful guide https://www.sparkred.com/blog/writing-a-custom-atg-cache/
The Actor chain definition will change a little bit to use the cache instead of the service, that will look like:


Give it a try.