// MARKET PLACE
engineBoSession = (EngineBoSession) setSessionMarketPlace(engineBoSession, newMarketPlace);
updateCurrentTheme(request, newMarketPlace.getTheme());
// MARKET
Market market = newMarketPlace.getMarket(marketCode);
if (market == null) {
market = newMarketPlace.getDefaultMarket();
}
engineBoSession = (EngineBoSession) setSessionMarket(engineBoSession, market);
// MARKET AREA
MarketArea marketArea = market.getMarketArea(marketAreaCode);
if (marketArea == null) {
marketArea = market.getDefaultMarketArea();
}
engineBoSession = (EngineBoSession) setSessionMarketArea(engineBoSession, marketArea);
// LOCALE
Localization localization = marketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, defaultLocalization);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(localizationCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, defaultRetailer);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, defaultCurrency);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, currency);
}
}
} else {
Market market = engineBoSession.getCurrentMarket();
if (market != null && !market.getCode().equalsIgnoreCase(marketCode)) {
// CHANGE THE MARKET
Market newMarket = marketService.getMarketByCode(marketCode);
if (newMarket == null) {
newMarket = currentMarketPlace.getDefaultMarket();
}
engineBoSession = (EngineBoSession) setSessionMarket(engineBoSession, market);
updateCurrentTheme(request, newMarket.getTheme());
// MARKET AREA
MarketArea marketArea = newMarket.getMarketArea(marketAreaCode);
if (marketArea == null) {
marketArea = market.getDefaultMarketArea();
}
engineBoSession = (EngineBoSession) setSessionMarketArea(engineBoSession, marketArea);