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
- Insert_update product; code[unique=true];minOrderQty;maxOrderQty
- 10001;1;99
- 10002;1;99
- 10003;1;99
Insert_update product; code[unique=true];minOrderQty;maxOrderQty 10001;1;99 10002;1;99 10003;1;99
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
- $productCatalog=powertoolsProductCatalog
- $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
- # Language
- $lang=en
- # Update All Products of powertoolsProductCatalog Staged version
- UPDATE Product[batchmode=true]; $catalogVersion; minOrderQty ; maxOrderQty
- ;;1;99
$productCatalog=powertoolsProductCatalog $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged] # Language $lang=en # Update All Products of powertoolsProductCatalog Staged version UPDATE Product[batchmode=true]; $catalogVersion; minOrderQty ; maxOrderQty ;;1;99
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
- # set all BundleTemplates in approved status
- UPDATE Customer[batchmode=true];itemtype(code)[unique=true];emailPreference
- ;Customer;true
# set all BundleTemplates in approved status UPDATE Customer[batchmode=true];itemtype(code)[unique=true];emailPreference ;Customer;true
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
- REMOVE Customer[ batchmode=true];itemtype (code)[unique=true]
- ;Customer
REMOVE Customer[ batchmode=true];itemtype (code)[unique=true] ;Customer
Some more examples
Update with item type as unique column
- # set all BundleTemplates in approved status
- UPDATE BundleTemplateStatus[batchmode=true];itemtype(code)[unique=true];status(code)
- ;BundleTemplateStatus;approved
# set all BundleTemplates in approved status UPDATE BundleTemplateStatus[batchmode=true];itemtype(code)[unique=true];status(code) ;BundleTemplateStatus;approved
Update with unique column other than item type
- $productCatalog=powertoolsProductCatalog
- $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
- # Update All Products
- UPDATE Product[batchmode=true]; $catalogVersion; unitOfMeasure ; unspcs
- ; ; C62 ; 23291500
$productCatalog=powertoolsProductCatalog $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged] # Update All Products UPDATE Product[batchmode=true]; $catalogVersion; unitOfMeasure ; unspcs ; ; C62 ; 23291500
Remove with item type as unique column
- REMOVE SapB2BDocument[ batchmode=true];itemtype (code)[unique=true]
- ;SapB2BDocument
REMOVE SapB2BDocument[ batchmode=true];itemtype (code)[unique=true] ;SapB2BDocument
Remove with unique column other than item type
- REMOVE ValidComponentTypesForContentSlots[batchMode=true];target(code)[unique=true]
- ;CMSImageComponent
REMOVE ValidComponentTypesForContentSlots[batchMode=true];target(code)[unique=true] ;CMSImageComponent
Note: 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
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 .
HYBRIS
Hi Karibasappa, Good Explanation.
Can we alter the column size using IMPEX Script? How?
Hi,
We can directly run the above query in HAC?
Yes, we can using “SQL Query” option under flexible search console
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 ?
No, that’s where scenario 2 , option “B” in the above article rescues
Very good explanation…..thanks a lot plz keep updating new things
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.