We all know that we use impex to insert,update and remove the data
You can read Impex basics here Overview Of Impex

Sometime its required for us to update value of few attributes (columns in table) for more than one instance (row in table)

Example :
I want to update the maxOrderQty and minOrderQty of all products

Here, We can do this using traditional way by specifying an each product’s unique code and updating values as below

  1. Insert_update product; code[unique=true];minOrderQty;maxOrderQty
  2. 10001;1;99
  3. 10002;1;99
  4. 10003;1;99
Insert_update product; code[unique=true];minOrderQty;maxOrderQty

In this way we have to specify unique attribute of Product for each instance and this is quiet manageable if we have few products to update.

Let us assume we have to update this to all products in our application

Let’s say volume is around 2000 products.

It’s very difficult to specify all 2000 products in impex to update these 2 attributes.
So, solution to achieve this without specifying all products in impex is Batch Mode.

Batch Mode: It’s a feature within Hybris Impex which allows to update more than one instance of item type.

In other words it allows us to do bulk update
We just need to use [batchmode=true] in the impex header

1. If the batch mode is not specified (as by default), the hybris throws an exception if more than one instance matches for a value line.

2. If the batch mode is enabled, the hybris modifies all instances that matches the value line

Solution to above problem(updating all products) with Batch mode is as below

  1. $productCatalog=powertoolsProductCatalog
  2. $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
  4. # Language
  5. $lang=en
  7. # Update All Products of powertoolsProductCatalog Staged version
  8. UPDATE Product[batchmode=true]; $catalogVersion; minOrderQty ; maxOrderQty
  9. ;;1;99

# Language

# Update All Products of powertoolsProductCatalog Staged version
UPDATE Product[batchmode=true]; $catalogVersion; minOrderQty ; maxOrderQty

In the above example, we specify $catalogVersion as unique column
So all product instances belonging to Staged version of powertoolsProductCatalog will be updated

Example: Update All customers without specifying any unique value

  1. # set all BundleTemplates in approved status
  2. UPDATE Customer[batchmode=true];itemtype(code)[unique=true];emailPreference
  3. ;Customer;true
# set all BundleTemplates in approved status
UPDATE Customer[batchmode=true];itemtype(code)[unique=true];emailPreference

We can also use Batch mode on Remove operation

Example: If we want to remove all customers
We can use Batchmode with remove as below

  1. REMOVE Customer[ batchmode=true];itemtype (code)[unique=true]
  2. ;Customer
REMOVE Customer[ batchmode=true];itemtype (code)[unique=true]

Some more examples

Update with item type as unique column

  1. # set all BundleTemplates in approved status
  2. UPDATE BundleTemplateStatus[batchmode=true];itemtype(code)[unique=true];status(code)
  3. ;BundleTemplateStatus;approved
# set all BundleTemplates in approved status
UPDATE BundleTemplateStatus[batchmode=true];itemtype(code)[unique=true];status(code)

Update with unique column other than item type

  1. $productCatalog=powertoolsProductCatalog
  2. $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
  4. # Update All Products
  5. UPDATE Product[batchmode=true]; $catalogVersion; unitOfMeasure ; unspcs
  6. ;   ;   C62 ;   23291500

# Update All Products
UPDATE Product[batchmode=true]; $catalogVersion; unitOfMeasure ; unspcs
;	;	C62	;	23291500

Remove with item type as unique column

  1. REMOVE SapB2BDocument[ batchmode=true];itemtype (code)[unique=true]
  2. ;SapB2BDocument
REMOVE SapB2BDocument[ batchmode=true];itemtype (code)[unique=true]

Remove with unique column other than item type

  1. REMOVE ValidComponentTypesForContentSlots[batchMode=true];target(code)[unique=true]
  2. ;CMSImageComponent
REMOVE ValidComponentTypesForContentSlots[batchMode=true];target(code)[unique=true]

We can use item type as one of the unique value in header if we want to update all instances of that type

We can specify unique value in header other than item type if we want to update matching instances for that unique value rather than all instances

Share this article on

Comment (8)

  1. Chandrashekharchavan

    Hi Karibasppa,

    can you suggest me As hybris tester what and all concepts to learn . how to good be in topics , if you have any study material please send on mail , it should be great for me .


  2. Just changing the items.xml and doing system update (can be done on Production environment) is not enough ? I thought System update will take care of changes in the definition of Item type in items.xml fie ?

  3. Sir, I want to add the new field in registration page on the given hybris website.what are changes are to be made.plse let me known.

Leave a Comment

  • You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">

    • Please answer this simple challenge to post your valuable comment *