Hybris ImpEx Operations

Hybris Impex Operations
Hybris Impex functionality plays very important role. With the help of impex (Import and Export Utility) we can perform multiple operations to ease our development process. Below we are going to discuss few useful operations which hybris provides.
Import APIs
Import Syntax:

We can write Simple Impex in 3 ways.

INSERT, UPDATE or REMOVE 

INSERT_UPDATE User;uid[Unique=true];emailid                    ;Name
                  ;TechWringer     ;TechWringer@techwringer-com;Tech Wringer
It will insert the record in DB if not exist, if it is already Exist then it will update the record.

INSERT User; uid[Unique=true];emailid                    ;Name
           ; TechWringer     ;TechWringer@techwringer-com;Tech Wringer
It will only insert the records which not exist in DB.

UPDATE User;uid[Unique=true];emailid                    ;Name
           ;TechWringer     ;TechWringer@techwringer-com;Tech Wringer
It will update the existing records.

REMOVE User; uid[Unique=true]
           ; TechWringer
It will remove the particular record or records which you want to remove from system.

  • Legacy Mode: Enable or Disable Service Layer
  • Max Threads: You can increase the thread count based on machine configuration.
  • Enable Code Execution
  • Distributed Modes: Running Execution on multiple nodes and clusters available.
Other Modes
Getting Data from property file in impex:

# Import modulegen config properties into impex macros
UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

# End point URL for the environments with one solr server
$solrEndPointUrl=$config-solr.master.url ----> Property available in local.properties

INSERT_UPDATE SolrEndpointUrl; solrServerConfig(name)[unique = true]; url[unique = true]      ; master[unique = true, default = false]
                                                    ; $ServerConfigName                             ; $solrEndPointUrl         ; true

Different Modes:

UPDATE User [batchmode=true];pk[unique=true];name   (Batch Mode only works with UPDATE)
;<UserPK>;"Tech Wringer"

Macro Inclusion in Impex:

$productCatalog = ProductCatalog
$productCatalogName = Product Catalog
$catalogVersion = catalogversion(catalog(id[default=$productCatalog]), version[default='Staged'])[unique=true, default=$productCatalog:Staged]
$lang = en_US
$supercategories = supercategories(code, $catalogVersion)
$baseProduct = baseProduct(code, $catalogVersion)
$approved = approvalstatus(code)[default='approved']

INSERT_UPDATE Product; code[unique = true]; $supercategories[mode=append];$catalogVersion; unit(code)[default = ea]
;product1;

For Date:
creationtime[forceWrite=true,dateformat=dd.MM.yyyy hh:mm:ss]

Allow Null:
source(&Item)[unique=true,allownull=true]
Auto Suggestions

Hybris Impex Preprocessor: Impex PLUS – hybrismart | SAP Commerce Cloud under the hood | SAP hybris

Export API
Flexible Search Query in the export:

insert_update ContentPage;uid[unique=true];name;catalogVersion;approvalStatus;label;title[lang=de];masterTemplate
"#% impex.exportItemsFlexibleSearch(""select {pk} from {ContentPage} where {CatalogVersion}=1234567890"");"

Direct With Type without Query:
insert_update ContentPage;uid[unique=true];name;catalogVersion;approvalStatus;label;title[lang=de];masterTemplate
"#% impex.exportItems(""ContentPage"", false);"
RSS
Share