use of com.salesmanager.core.model.catalog.product.variation.ProductVariation in project shopizer by shopizer-ecommerce.
the class ProductVariationFacadeImpl method update.
@Override
public void update(Long variationId, PersistableProductVariation var, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
Validate.notNull(var, "PersistableProductVariation cannot be null");
Optional<ProductVariation> p = productVariationService.getById(store, variationId, language);
if (p.isEmpty()) {
throw new ResourceNotFoundException("ProductVariation not found for id [" + variationId + "] and store [" + store.getCode() + "]");
}
ProductVariation productVariant = p.get();
productVariant.setId(variationId);
productVariant.setCode(var.getCode());
ProductVariation model = persistableProductVariationMapper.merge(var, productVariant, store, language);
try {
model.setMerchantStore(store);
productVariationService.save(model);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while creating ProductVariation", e);
}
}
use of com.salesmanager.core.model.catalog.product.variation.ProductVariation in project shopizer by shopizer-ecommerce.
the class ProductVariationFacadeImpl method get.
@Override
public ReadableProductVariation get(Long id, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
ProductVariation variation = productVariationService.getById(store, id, language);
if (variation == null) {
throw new ResourceNotFoundException("ProductVariation not found for id [" + id + "] and store [" + store.getCode() + "]");
}
return readableProductVariationMapper.convert(variation, store, language);
}
Aggregations