CartItem cartItem = (CartItem) event.getSourceObject();
FoCartItemPojo cartItemPojo = (FoCartItemPojo) event.getDestinationObject();
try {
final RequestData requestData = requestUtil.getRequestData(httpServletRequest);
final MarketArea marketArea = requestData.getMarketArea();
final Retailer retailer = requestData.getMarketAreaRetailer();
final Localization localization = requestData.getMarketAreaLocalization();
final String localizationCode = localization.getCode();
final Asset defaultPackshotImage = cartItem.getProductSku().getDefaultPackshotImage(ImageSize.SMALL.name());
if (defaultPackshotImage != null) {
String summaryImage = engineSettingService.getProductMarketingImageWebPath(defaultPackshotImage);
cartItemPojo.setSummaryImage(summaryImage);
} else {
cartItemPojo.setSummaryImage("");
}
cartItemPojo.setI18nName(cartItem.getProductSku().getI18nName(localizationCode));
cartItemPojo.setProductDetailsUrl(urlService.generateUrl(FoUrls.PRODUCT_DETAILS, requestData, cartItem.getCatalogCategory(), cartItem.getProductMarketing(), cartItem.getProductSku()));
cartItemPojo.setPriceWithStandardCurrencySign(cartItem.getPriceWithStandardCurrencySign(marketArea.getId(), retailer.getId()));
cartItemPojo.setTotalAmountWithStandardCurrencySign(cartItem.getTotalAmountWithStandardCurrencySign(marketArea.getId(), retailer.getId()));
} catch (Exception e) {
logger.error("postWritingDestinationValue error with FoCartItemPojo", e);
}
}
} else if(event.getDestinationObject() instanceof ProductSkuPojo){
if(event.getFieldMap().getDestFieldName().equals("code")){
// INJECT BACKOFFICE URLS
ProductSku productSku = (ProductSku) event.getSourceObject();
ProductSkuPojo productSkuPojo = (ProductSkuPojo) event.getDestinationObject();
try {
final RequestData requestData = requestUtil.getRequestData(httpServletRequest);
final MarketArea marketArea = requestData.getMarketArea();
final Retailer retailer = requestData.getMarketAreaRetailer();
final Localization localization = requestData.getMarketAreaLocalization();
final String localizationCode = localization.getCode();
final Asset defaultPackshotImage = productSku.getDefaultPackshotImage(ImageSize.SMALL.name());
if (defaultPackshotImage != null) {
String summaryImage = engineSettingService.getProductMarketingImageWebPath(defaultPackshotImage);
productSkuPojo.setDefaultPackshotImage(summaryImage);
} else {
productSkuPojo.setDefaultPackshotImage("");
}
productSkuPojo.setI18nName(productSku.getI18nName(localizationCode));
ProductSkuPrice price = productSku.getPrice(marketArea.getId(), retailer.getId());
if(price != null){
productSkuPojo.setPriceWithStandardCurrencySign(price.getPriceWithStandardCurrencySign());
}
} catch (Exception e) {