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 

Този материал е лицензиран под лиценз Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported  Публикациите в Twitter™ и Facebook не попадат под клаузите на Creative Commons.

Правни бележки   |   Правила за онлайн поверителност