Impex is the main way to import data into the Hybris eCommerce Suite. It is based on CSV and offer additional features like scripting, handling of maps and collections and removal of items.

Examples

Importing a property with a map 

INSERT_UPDATE BTGConfig[unique=true];defaultTimeUnit(code);usedRuleTypes(code);operandMapping(key(code),value(code))[map-delimiter=|]
BTGConfig;WEEK;ORDER,CART,USER,WCMS;ORDER->BTGOrganizationTotalSpentInCurrencyRelativeDatesOperand,BTGOrganizationTotalSpentInCurrencyLastYearOperand,BTGNumberOfOrdersAboveAmountRelativeDateOperand,BTGCategoriesInOrdersOperand,BTGEachOrderTotalSumOperand,BTGOrderTotalSumOperand,BTGProductsInOrdersOperand,BTGNumberOfOrdersOperand,BTGNumberOfOrdersRelativeDateOperand,BTGLastOrderDateOperand|CART->BTGCartIsEmptyOperand,BTGCartTotalSumOperand,BTGCategoriesInCartOperand,BTGProductsInCartOperand,BTGQuantityOfProductInCartOperand|WCMS->BTGViewedProductsOperand,BTGViewedCategoriesOperand,BTGVisitedContentpagesOperand,BTGReferalUrlOperand,BTGUrlParameterOperand|USER->BTGOrganizationUIDOfUserOperand,BTGUserAddressPostalCodeOperand,BTGUserCountryOperand,BTGUserGenderOperand,BTGUserMemberOfGroupsOperand|SCRIPT->BTGMediaScriptOperand,BTGStringScriptOperand

The last column contains the values for a property defined as map<BTGRuleType, BTGOperandTypeCollection>

Based on Hybris 5.3

Importing two objects which depend on each other with mandatory fields

Suppose that the following relation is defined:

      <relation code="B2BUser2Lagerhaus" autocreate="true" generate="true" localized="false">
         <deployment table="b2bUsers2Lagerhaeuser" typecode="15067"/>
         <sourceElement qualifier="b2bZentralbesteller" type="B2BUser" cardinality="many">
            <modifiers optional="false"/>
         </sourceElement>
         <targetElement qualifier="b2bLagerhaeuser" type="Lagerhaus" cardinality="many">
            <modifiers optional="false"/>
         </targetElement>
      </relation>

The following Impex Scripts adds an user and a lagerhaus at the same time:

INSERT_UPDATE B2BUser;UID[unique=true];groups(uid)[mode=append];b2bLagerhaeuser(uid);
#% impex.setValidationMode("import_relaxed");
;dummyB2BUser;;LH_200

INSERT_UPDATE Lagerhaus;uid[unique=true];id;locname;rechtsform;homepage;mandantId;b2bZentralbesteller(uid)
;LH_200;200;Lagerhaus Aubing;eGen;http://www.acme.de;200;dummyB2BUser

Relaxing the validation means that Hybris doesn't check the mandatory fields. The use of item references with the symbol & don't solve this issue.

Testing if a condition is meet

This is an example on how to use if statements in Impex

#Due to the initial attributes, we cannot update the execution result, we can only insert them if they doesn't exist.
#% if: de.hybris.platform.core.Registry.getApplicationContext().getBean(de.hybris.platform.servicelayer.search.FlexibleSearchService.class).search("SELECT {r.PK} FROM {ScriptExecutionResult as r}").getCount() == 0;
INSERT ScriptExecutionResult;name[unique=true];canBeRunnedAgain[forceWrite=true];description[lang=en];
;SUCCESS;false;Success;
;ERROR;true;Error;
#% endif:

 

Based on Hybris 6.5

Add comment


Security code
Refresh