Creating Command Components

Trying to create cartCreateCommand. Need some information on Command Components creation and mapping.

Hi,
I guess you’re referring to the StarterStore. If that’s the case, the cartCreateCommand is responsible for creating the cart object directly in your e-commerce backend. Once that object is created in the backend, then you may want to handle information like cartId, revision number directly from your XM application. As an example, in the release 1.X of the StarterStore you can simply store the “cartId” in a cookie.

You can “associate” your cart command to any StarterStore page, filling the commands field property with the right value: for more information about the pattern adopted by the StarterStore components, you can have a look here [1].

HTH,

Giacomo

[1] https://documentation.bloomreach.com/12/library/solutions/commerce-starterstore/framework.html

Hi
Thanks for the information. It was very helpful. I am just missing one thing, how do we configure module (from modules command class objects are pulled) for custom command classes in new packages.

Thanks

Hi,
glad that my previous answer helped.
If you want to add a custom command in your StarterStore based application, you need to

  1. Add the @Component annotation to your custom command class
  2. Enable Spring Framework auto scan in your project.

You can pretty much follow this documentation page [1]. Just consider that if you leave the component annotation empty, then you can just reference to your command using the class name (first letter lower case!)

HTH,
Giacomo

[1] https://documentation.bloomreach.com/library/concepts/web-application/spring-managed-hst-components.html