How can I set B2B Unit in session. I have facade class which implements logic to set units in session (ex. When one user is login in storefront give me his units and set these units in session). This is my method in custom class which extedns DefaultCustomerFacade.class
@Override
public void loginSuccess(){
Set<B2BUnitModel> allUserGroupsForUser = getUserService().getAllUserGroupsForUser(getCurrentUser(), B2BUnitModel.class);
List<String> b2bunitIds = allUserGroupsForUser.stream()
.map(B2BUnitModel::getName)
.collect(Collectors.toList());
if(!allUserGroupsForUser.isEmpty()) {
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);
}
super.loginSuccess();
}
Then in storefront, I showed in select tag in jsp, drop-down with these units. Ok, so I have attribute now with these units which is in session and I want when I click for some B2B Unit, this one unit to set in session. I think, I shoud do some controller to implement logic ( set currentUnit in session ) and in one js file to make some ajax call with some method onChange, or some ajax api, but I don't know how to do this. Can someone help me, i am new in hybris and I will be glad if someone help me