Saturday, January 27, 2018

How to integrate Adobe Experience Manager(AEM) and SAP Hybris through OOB connector

How to integrate Adobe Experience Manager(AEM) and SAP Hybris through OOB connector


This post explains the detailed steps for AEM and Hybris integration through OOB connector. AEM comes with default Hybris connector and sample demo site(should be downloaded via package manager), the steps covered in the post is for integrating AEM 6.3 with Hybris 6.1 but the same steps works for other AEM and Hybris versions with minimal changes.

AEM Configuration:


Install JDK 8
Install AEM 6.3 server
Install cq-geometrixx-all-pkg-5.10.68.zip, cq-geometrixx-hybris-content-6.3.2.zip and cq-hybris-content-6.3.2.zip packages from package share (I am considering geo-metrixx for demo, we.retail should be the recommended one in AEM 6.3)

aem-hybris-integration-packages

Change the Hybris server version in "Day CQ Commerce Hybris Configuration", ignore to default value if the specified version is not listed.

aem-hybris-integration-hybris-version

Change the Hybris OAuth endpoint in "Hybris OAuth Handler" based on the Hybris version, /authorizationserver/oauth/token for Hybirs 6 and later and /rest/oauth/token for earlier Hybris versions   - This step can be ignored for AEM 6.3 as the connectes defaults the values based on the Hybris version selected in the previous step.

aem-hybris-integration-OAuth-url

If the OAuth URL is not configured with correct value then the below exception will be displayed in error log

com.adobe.cq.commerce.hybris.impl.OAuthHandler Server did not respond with 2xx -> authentication failed.


Hybris configuration:


Install JDK 8(based on the Hybris version, later Hybris 6 versions required JDK 8)
Extract the installer

Execute the below commend

cd <hybris-root-directory>/installer
install -r b2c_acc

Add the below extensions into HYBRIS_HOME/config/localextentions.xml- the hmc is deprecated in later 6 versions so can be ignored

<extension name='admincockpit'></extension>
<extension name='cockpit'></extension>
<extension name='hmc'></extension>
<extension name='platformhmc'></extension>
<extension name='workflow'></extension>
<extension name='processing'></extension>
<extension name='productcockpit'></extension>
<extension name='importcockpit'></extension>
<extension name='classificationsystems'></extension>
<extension name='classificationsystemshmc'></extension>

aem-hybris-integration-hybris-extentions


Download setup.groovy and place it under Hybris root - Refer https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/hybris.html to get the file based on the Hybris version.

Change the spring-security path in setup.groovy to "bin/ext-template/ycommercewebservices/web/webroot/WEB-INF/config/common/security-spring.xml" - this step is required only for later 6 Hybris versions

Execute the below commands - the groovy should be installed in the system before executing the below commands

cd ..
groovy setup.groovy
cd bin/platform
setantenv
ant clean all - Select the default configuration template(development)
hybrisserver (starting the server)

aem-hybris-integration-hybris-conf-template

The above step will take some time, after completion Login to https://localhost:9002 and click on initialize and wait for initialize to complete

aem-hybris-integration-hybris-initialize


Download  geometrixx-outdoors-export.csv, geometrixx-outdoors-images.zip  and  base-store.csv(based on the Hybris version) from https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/hybris.html

Import geometrixx-outdoors-export.csv and geometrixx-outdoors-images.zip:


Login to https://localhost:9002/hmc/hybris and navigate to System==>Tools==>Import

aem-hybris-integration-hybris-media-import

Select import file geometrixx-outdoors-export in Configuration tab
Select the Locale Setting as en_English

aem-hybris-integration-hybris-media-import


aem-hybris-integration-hybris-media-import

Select geometrixx-outdoors-images in Resources tab

aem-hybris-integration-hybris-media-import

Click on Start - wait for completion of the import job

aem-hybris-integration-hybris-media-import


Import base-store.csv:


Follow the above steps and import base-store.csv

aem-hybris-integration-hybris-catalog-import


Verify the product - Login to https://localhost:9002/productcockpit and make sure the sample products are imported without any issue

aem-hybris-integration-hybris-productcockpit-verify


Define OAuth Clients in Hybris:



Login to https://localhost:9002/backoffice and navigate to System==>OAuth==> OAuth Clients and define mobile_android and trusted_client with the following configurations

aem-hybris-integration-hybris-oauth-clients


OAuth Client ID -  mobile_android
Client secret -  secret
OAuth resource IDs - hybris
scope - basic
Client Grant Types - authorization_code,refresh_token,password,client_credentials
Authorities - ROLE_CLIENT

aem-hybris-integration-hybris-oauth-clients

aem-hybris-integration-hybris-oauth-clients

aem-hybris-integration-hybris-oauth-clients

aem-hybris-integration-hybris-oauth-clients


OAuth Client ID -  trusted_client
Client secret -  secret
OAuth resource IDs - hybris
scope - extended
Client Grant Types - authorization_code,refresh_token,password,client_credentials
Authorities - ROLE_TRUSTED_CLIENT

aem-hybris-integration-hybris-oauth-clients


If the OAuth client are not configured properly then the below exception will be displayed in AEM error log while accessing the services

com.adobe.cq.commerce.hybris.impl.OAuthHandler Server did not respond with 2xx -> authentication failed.


Set the stock level for a product:



By default all the products will have the stock level defined as 0, for demo purpose i am change the stock level of one product

Login to https://localhost:9002/ and navigate to console Impex Import
Execute the below script

$productCatalog=outdoors

$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default=’Staged’])[unique=true,default=$productCatalog:Staged]

INSERT_UPDATE StockLevel;productCode[unique=true];warehouse(code)[unique=true,default=default];available;inStockStatus(code);maxPreOrder[default=1];maxStockLevelHistoryCount[default=-1];overSelling[default=0];preOrder[default=0];reserved[default=0]

;023984-S;geometrixx01;100;forceInStock

aem-hybris-integration-hybris-update-product-stock-level


Add the name and description for missing delivery modes:



By default the name and description is missing for some of the delivery modes in Hybris, this will create problem while checking out the order.

Caused by: org.apache.sling.commons.json.JSONException: JSONObject["name"] not found.
at org.apache.sling.commons.json.JSONObject.get(JSONObject.java:360)
at com.adobe.cq.commerce.hybris.importer.DefaultResponseParser.parseDeliveryMode(DefaultResponseParser.java:1329)
at com.adobe.cq.commerce.hybris.importer.DefaultResponseParser.parseDeliveryModes(DefaultResponseParser.java:1318)
at com.adobe.cq.commerce.hybris.importer.DefaultResponseParser.parseDeliveryModes(DefaultResponseParser.java:1304)
at com.adobe.cq.commerce.hybris.common.DefaultHybrisSession.getShippingMethodsInternal(DefaultHybrisSession.java:1680)

To fix the issue add some dummy name and description for delivery modes.

Login to https://localhost:9002/backoffice/ and Navigate to Price Settings ==> Delivery Costs

aem-hybris-integration-hybris-delivery-methods

Add the Name and description for missing delivery modes

aem-hybris-integration-hybris-delivery-methods

Now the e-Store can be accessed via http://localhost:4503/content/geometrixx-outdoors/en_US.html

Open http://localhost:4503/content/geometrixx-outdoors/en_US/men/shirts/bambara-cargo.html(as the stock is set for only this product for testing)

aem-hybris-integration-hybris-sample-checkout

Click on add to cart

aem-hybris-integration-hybris-sample-checkout


Perform the checkout by enter the address values and card details, use 0000000000000000 as the card number for testing

aem-hybris-integration-hybris-sample-checkout


aem-hybris-integration-hybris-sample-checkout


aem-hybris-integration-hybris-sample-checkout

To verify the order from Hybris, Login to https://localhost:9002/backoffice and navigate to Order==>Orders

aem-hybris-integration-hybris-sample-checkout

aem-hybris-integration-hybris-sample-checkout

Download the configuration files - ConfigurationFiles


2 comments: