CommerceService is undefined or null when Geometrixx is not installed

Issue

When trying to adapt the resource resolver to a CommerceService object, for example in the code below, then it returns null or "undefined":

var commerceService = resource. getResourceResolver(). adaptTo( com. adobe. cq. commerce. api.CommerceService); 

In this case, the class com.adobe.cq.commerce.api.CommerceService is available in the OSGi Class Loader. To confirm this, refer to the OSGi console using the http://aem-host:port/system/console/depfinder tool. 

 

Cause

This issue is by design.

Resolution

Implement your own versions of the services provided in the cq-geometrixx-commons-core bundle provided under /apps/geometrixx-commons, when implementing an application using the AEM Commerce APls.

The Geometrixx ones are just samples, and it is not recommended to install Geometrixx in production, for security reasons. If you do not implement your own version of the CommerceServiceFactory, then you would run into the issue described above if Geometrixx is not installed. 

See the sample source code that ships with AEM under these paths: 

/apps/geometrixx-
commons/src/core/src/main/java/info/geometrixx/commons/impl/GeoCommerceServicelmpl.java 
/apps/geometrixx-
commons/src/core/src/main/java/info/geometrixx/commons/impl/GeoCommerceServiceFactory.java 
/apps/geometrixx-
commons/src/core/src/main/java/info/geometrixx/commons/impl/GeoCommerceSessionlmpl.java 
/apps/geometrixx-commons/src/core/src/main/java/info/geometrixx/commons/impl/productrelationships 

 Adobe

쉽고 빠르게 지원 받기

신규 사용자이신가요?

Adobe MAX 2024

Adobe MAX

The Creativity Conference

10월 14~16일 마이애미 비치 및 온라인

Adobe MAX 2024

Adobe MAX

The Creativity Conference

10월 14~16일 마이애미 비치 및 온라인