cancel
Showing results for 
Search instead for 
Did you mean: 

How I can change the user who execute the impex created by hotfolder?

Mpcasas
Explorer

Hi experts!

By default the user who execute the impex created by hotfolder is anonymous, but I would like changed the user because I need use a user with admingroup.

In my case, I developed a hotfolder to create B2BUnits but I B2BUnitModelValidateInterceptor throws the exception because anonymous doesn't have admingroup. I attach the snapshot where the exception was thrown it

Thank you very much for your help and best regards

Accepted Solutions (1)

Accepted Solutions (1)

former_member629054
Discoverer

Hi Maria,

Impex API provides a way to execute Java Code blocks before you execute an Import Statement.Below is the given Syntax.

#% <Code Block>
INSERT_UPDATE <ItemType>;<attribute>[Header Qualifiers];<attribute>[Header Qualifiers]

From from your Question it looks like you may have to change the Session user before executing the script which could look something like below

#% import de.hybris.platform.core.Registry 
#% import de.hybris.platform.servicelayer.user.UserService
#% import de.hybris.platform.core.model.user.UserModel
#% UserService userService = Registry.getApplicationContext().getBean("userService")
#% userService.setCurrentUser((UserModel)userService.getAdminUser())
INSERT_UPDATE B2BUnit;uid[unique=true];name[lang=en]
;1234556;"Example"

The Above is also applicable to Hot Folders

Answers (0)