use of com.salesmanager.shop.model.catalog.product.LightPersistableProduct in project shopizer by shopizer-ecommerce.
the class ProductCommonFacadeImpl method update.
@Override
public void update(Long productId, LightPersistableProduct product, MerchantStore merchant, Language language) {
// Get product
Product modified = productService.findOne(productId, merchant);
// Update product with minimal set
modified.setAvailable(product.isAvailable());
for (ProductAvailability availability : modified.getAvailabilities()) {
availability.setProductQuantity(product.getQuantity());
if (!StringUtils.isBlank(product.getPrice())) {
// set default price
for (ProductPrice price : availability.getPrices()) {
if (price.isDefaultPrice()) {
try {
price.setProductPriceAmount(pricingService.getAmount(product.getPrice()));
} catch (ServiceException e) {
throw new ServiceRuntimeException("Invalid product price format");
}
}
}
}
}
try {
productService.save(modified);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Cannot update product ", e);
}
}
use of com.salesmanager.shop.model.catalog.product.LightPersistableProduct in project shopizer by shopizer-ecommerce.
the class ProductFacadeImpl method update.
@Override
public void update(Long productId, LightPersistableProduct product, MerchantStore merchant, Language language) {
// Get product
Product modified = productService.findOne(productId, merchant);
// Update product with minimal set
modified.setAvailable(product.isAvailable());
for (ProductAvailability availability : modified.getAvailabilities()) {
availability.setProductQuantity(product.getQuantity());
if (!StringUtils.isBlank(product.getPrice())) {
// set default price
for (ProductPrice price : availability.getPrices()) {
if (price.isDefaultPrice()) {
try {
price.setProductPriceAmount(pricingService.getAmount(product.getPrice()));
} catch (ServiceException e) {
throw new ServiceRuntimeException("Invalid product price format");
}
}
}
}
}
try {
productService.save(modified);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Cannot update product ", e);
}
}
Aggregations