use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue in project shopizer by shopizer-ecommerce.
the class PersistableProductVariationMapper method merge.
@Override
public ProductVariation merge(PersistableProductVariation source, ProductVariation destination, MerchantStore store, Language language) {
Validate.notNull(destination, "ProductVariation cannot be null");
destination.setId(source.getId());
destination.setCode(source.getCode());
destination.setMerchantStore(store);
ProductOption option = productOptionService.getById(store, source.getOption());
if (option == null) {
throw new ConversionRuntimeException("ProductOption [" + source.getOption() + "] does not exists");
}
destination.setProductOption(option);
ProductOptionValue optionValue = productOptionValueService.getById(store, source.getOptionValue());
if (optionValue == null) {
throw new ConversionRuntimeException("ProductOptionValue [" + source.getOptionValue() + "] does not exists");
}
destination.setProductOptionValue(optionValue);
return destination;
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue in project shopizer by shopizer-ecommerce.
the class ProductOptionValueServiceImpl method delete.
public void delete(ProductOptionValue entity) throws ServiceException {
// remove all attributes having this option
List<ProductAttribute> attributes = productAttributeService.getByOptionValueId(entity.getMerchantStore(), entity.getId());
for (ProductAttribute attribute : attributes) {
productAttributeService.delete(attribute);
}
ProductOptionValue option = getById(entity.getId());
// remove option
super.delete(option);
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue in project shopizer by shopizer-ecommerce.
the class ProductOptionFacadeImpl method optionValues.
@Override
public ReadableProductOptionValueList optionValues(MerchantStore store, Language language, String name, int page, int count) {
Validate.notNull(store, "MerchantStore should not be null");
Page<ProductOptionValue> options = productOptionValueService.getByMerchant(store, null, name, page, count);
ReadableProductOptionValueList valueList = new ReadableProductOptionValueList();
valueList.setTotalPages(options.getTotalPages());
valueList.setRecordsTotal(options.getTotalElements());
valueList.setNumber(options.getNumber());
List<ReadableProductOptionValueEntity> values = options.getContent().stream().map(option -> readableOptionValueMapper.convert(option, store, null)).collect(Collectors.toList());
valueList.setOptionValues(values);
return valueList;
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue in project shopizer by shopizer-ecommerce.
the class ProductOptionFacadeImpl method optionValueExists.
@Override
public boolean optionValueExists(String code, MerchantStore store) {
Validate.notNull(code, "Option value code must not be null");
Validate.notNull(store, "Store code must not be null");
boolean exists = false;
ProductOptionValue optionValue = productOptionValueService.getByCode(store, code);
if (optionValue != null) {
exists = true;
}
return exists;
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue in project shopizer by shopizer-ecommerce.
the class ProductOptionFacadeImpl method addOptionValueImage.
@Override
public void addOptionValueImage(MultipartFile image, Long optionValueId, MerchantStore store, Language language) {
Validate.notNull(optionValueId, "OptionValueId must not be null");
Validate.notNull(image, "Image must not be null");
// get option value
ProductOptionValue value = productOptionValueService.getById(store, optionValueId);
if (value == null) {
throw new ResourceNotFoundException("Product option value [" + optionValueId + "] not found");
}
try {
String imageName = image.getOriginalFilename();
InputStream inputStream = image.getInputStream();
InputContentFile cmsContentImage = new InputContentFile();
cmsContentImage.setFileName(imageName);
cmsContentImage.setMimeType(image.getContentType());
cmsContentImage.setFile(inputStream);
contentService.addOptionImage(store.getCode(), cmsContentImage);
value.setProductOptionValueImage(imageName);
productOptionValueService.saveOrUpdate(value);
} catch (Exception e) {
throw new ServiceRuntimeException("Exception while adding option value image", e);
}
return;
}
Aggregations