use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ReferenceController method zoneName.
@RequestMapping(value = "/shop/reference/zoneName")
@ResponseBody
public String zoneName(@RequestParam String zoneCode, HttpServletRequest request, HttpServletResponse response) {
try {
Language language = languageUtils.getRequestLanguage(request, response);
if (language == null) {
return zoneCode;
}
Map<String, Zone> zonesMap = zoneService.getZones(language);
if (zonesMap != null) {
Zone z = zonesMap.get(zoneCode);
if (z != null) {
return z.getName();
}
}
} catch (ServiceException e) {
LOGGER.error("Error while looking up zone " + zoneCode);
}
return SanitizeUtils.getSafeString(zoneCode);
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ReferenceController method countryName.
@RequestMapping(value = "/shop/reference/countryName")
@ResponseBody
public String countryName(@RequestParam String countryCode, HttpServletRequest request, HttpServletResponse response) {
try {
Language language = languageUtils.getRequestLanguage(request, response);
if (language == null) {
return countryCode;
}
Map<String, Country> countriesMap = countryService.getCountriesMap(language);
if (countriesMap != null) {
Country c = countriesMap.get(countryCode);
if (c != null) {
return c.getName();
}
}
} catch (ServiceException e) {
LOGGER.error("Error while looking up country " + countryCode);
}
return StringEscapeUtils.escapeHtml4(countryCode);
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ProductFacadeV2Impl method getProductBySeUrl.
@Override
public ReadableProduct getProductBySeUrl(MerchantStore store, String friendlyUrl, Language language) throws Exception {
Product product = productService.getBySeUrl(store, friendlyUrl, LocaleUtils.getLocale(language));
if (product == null) {
throw new ResourceNotFoundException("Product [" + friendlyUrl + "] not found for merchant [" + store.getCode() + "]");
}
ReadableProduct readableProduct = readableProductMapper.convert(product, store, language);
// get all instances for this product group by option
// limit to 15 searches
List<ProductInstance> instances = productInstanceService.getByProductId(store, product, language);
// the above get all possible images
List<ReadableProductInstance> readableInstances = instances.stream().map(p -> this.productInstance(p, store, language)).collect(Collectors.toList());
readableProduct.setVariants(readableInstances);
return readableProduct;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ProductFacadeV2Impl method getProductByCode.
@Override
public ReadableProduct getProductByCode(MerchantStore store, String uniqueCode, Language language) {
Product product = productService.getByCode(uniqueCode, language);
if (product == null) {
throw new ResourceNotFoundException("Product [" + uniqueCode + "] not found for merchant [" + store.getCode() + "]");
}
if (product.getMerchantStore().getId() != store.getId()) {
throw new ResourceNotFoundException("Product [" + uniqueCode + "] not found for merchant [" + store.getCode() + "]");
}
ReadableProduct readableProduct = readableProductMapper.convert(product, store, language);
// get all instances for this product group by option
// limit to 15 searches
List<ProductInstance> instances = productInstanceService.getByProductId(store, product, language);
// the above get all possible images
List<ReadableProductInstance> readableInstances = instances.stream().map(p -> this.productInstance(p, store, language)).collect(Collectors.toList());
readableProduct.setVariants(readableInstances);
return readableProduct;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ProductInstanceFacadeImpl method list.
@Override
public ReadableEntityList<ReadableProductInstance> list(Long productId, MerchantStore store, Language language, int page, int count) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(productId, "Product id cannot be null");
Product product = productFacade.getProduct(productId, store);
if (product == null) {
throw new ResourceNotFoundException("Product with id [" + productId + "] not found for store [" + store.getCode() + "]");
}
Page<ProductInstance> instances = productInstanceService.getByProductId(store, product, language, page, count);
List<ReadableProductInstance> readableInstances = instances.stream().map(rp -> this.readableProductInstanceMapper.convert(rp, store, language)).collect(Collectors.toList());
return createReadableList(instances, readableInstances);
}
Aggregations