Parameterize Hybris ImpEx import by config data from local.properties

SAP HybrisThere are times you have to parameterize data which is being imported by Hybris ImpEx import. One example could be handling of environment specific parameters, like different development and production endpoints URLs of a particular interface etc. A solution is to use Hybris ConfigPropertyImportProcessor in .impex file.

ConfigPropertyImportProcessor class

When you check javadoc for this class, you can read this:

de.hybris.platform.commerceservices.impex.impl
public class ConfigPropertyImportProcessor
extends Object
implements ImportProcessor
Impex ImportProcessor that injects all config properties as impex definitions. All defined configuration properties are added as impex macro definitions with the prefix of “config-“. For example the config key mail.smtp.server can be accessed via the macro $config-mail.smtp.server. In order to use this import processor and to load the configuration properties the following must be added to the top of the impex file: UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

Javadoc is already self-explanatory but I’ll write a short example, for better understanding.

Example

Let’s say we have different ERP systems to integrate with, in development and production environments. In development we are using ERP sandbox server and for production – ERP production system. We’ll specify a parameter called erp-server-url in config files for development and production environments:

erp-server-url=https://sandbox.erp.com
erp-server-url=https://api.erp.com/v1

ImpEx file for importing the ERP endpoint URL could be coded like this:

UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]
$erpEndpointUrl=$config-erp.server.url

# Setup ERP transfer profile endpoint URL
INSERT_UPDATE ErpTransferProfile;code[unique=true];serverUrl
;ErpTransferProfile01;$erpEndpointUrl

When you import ImpEx file in development environment, the used ERP URL will be https://sandbox.erp.com. When this same ImpEx is executed with production config, https://api.erp.com/v1 will be used as ERP URL.

Find more Hybris ImpEx hints in this blog post.

SAP Hybris is an enterprise-level ecommerce software suite that offers B2C and B2B store functionality. Currently, more than 2,500 stores use the hybris platform, boasting more than 20 million product SKUs and over 500,000 orders each day. More information you can find at hybris.com.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.