Ensure License Compliance

Check whether you meet the required license compliance standards that are related to order metrics measured by SAP Commerce Cloud for billing purposes.

Context

The default implementation of SAP Commerce Cloud ensures that customer orders are passed on to the OrderService.submitOrder(order) service that is responsible for carrying out the post processing logic including order splitting and sourcing. SAP Commerce Cloud injects additional strategies to this service that calculate order metrics that are used by SAP for billing purposes. The out-of-the-box Accelerator and OCC templates include these strategies.

If you have modified the standard behavior, for example when customizing post processing in your project, you must manually trigger order measurement in your custom code to stay compliant with the SAP Commerce Cloud terms and conditions. If you're unsure whether your orders are measured, enable the following service properties for your environments:

businessmetrics.logging.active=true
log4j2.logger.om-measure.level=INFO
log4j2.logger.om-measure.name=businessmetrics.src.de.hybris.platform.businessmetrics.clients.LoggingClient

These properties ensure that every order creates a log line similar to the following:

Business metrics: ... -> ...

If you don't see the correct information in your logs, follow the steps:

Procedure

  1. In your custom extensions code, add the following code sample that triggers order measurement:
    import de.hybris.platform.core.Registry;
    import de.hybris.platform.core.model.order.OrderModel;
    import de.hybris.platform.order.strategies.SubmitOrderStrategy;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.BeansException;
    
    
    public class OrderMetricsHelper
    {
    
    	private static final Logger LOG = LoggerFactory.getLogger(OrderMetricsHelper.class);
    	private static final String BEAN_ID = "orderMetricsSubmitOrderStrategy";
    
    	/**
    	 * Triggers order metrics collection for the specified order on Commerce Cloud environments. Outside of that context
    	 * it will act as no-op and only log a warning that the order could not be submitted.
    	 */
    	public static void triggerMetrics(final OrderModel order)
    	{
    		final SubmitOrderStrategy bean = tryToFindBean();
    		if (bean != null)
    		{
    			bean.submitOrder(order);
    		}
    		else
    		{
    			LOG.warn("no strategy {} found - not submitting order {}", BEAN_ID, order.getCode());
    		}
    	}
    
    	static SubmitOrderStrategy tryToFindBean()
    	{
    		try
    		{
    			return Registry.getCoreApplicationContext().getBean(BEAN_ID, SubmitOrderStrategy.class);
    		}
    		catch (final BeansException e)
    		{
    			LOG.debug("Error finding order metrics bean", e);
    			return null;
    		}
    	}
    }
  2. Ensure that you invoke triggerMetrics(order) in your business logic every time time customers place their orders.

Results

SAP Commerce Cloud now passes order metrics to SAP. The process is asynchronous and shouldn't have a negative impact on the performance of SAP Commerce Cloud.