Thursday, December 21, 2017

Scenarios missing a subject

Scenarios in OC can be created to do actions based on the People/Profile properties

However you might face a problem when the scenario is waiting for a profile property and there is not a user in the scenario process execution context.

When this happen an exception like this will be thrown:

**** Error      Wed Dec 20 11:11:25 -07:00 2017 1513793485829   /atg/dynamo/messaging/MessagingManager  An error occurred while MessageSink with nucleus name "/atg/scenario/ScenarioManager" was receiving a Message from input port "IndividualEvents": javax.jms.JMSException: atg.process.ProcessException: Cannot obtain a subject required for an individual process execution context, from either the current request or message bean mycompany.commerce.messaging.ConfirmOrderStateMessage@79fbc732     javax.jms.JMSException: atg.process.ProcessException: Cannot obtain a subject required for an individual process execution context, from either the current request or message bean mycompany.commerce.messaging.ConfirmOrderStateMessage@79fbc732
**** Error      Wed Dec 20 11:11:25 -07:00 2017 1513793485829   /atg/dynamo/messaging/MessagingManager          at atg.process.ProcessManagerService.receiveMessage(ProcessManag
erService.java:11348)
.....

This is because there is not a profile that can be used to apply the Scenario, usually there is one, but when you create a custom event it might not be the case.

In order to avoid this you just need to make sure your Custom Message set the Profile you want to use as follows:
This is documented at https://docs.oracle.com/cd/E55783_02/Platform.11-2/ATGPersProgGuide/html/s2402associatingprofileswithindividua01.html


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.