use of com.salesmanager.core.model.catalog.product.attribute.ProductAttribute in project shopizer by shopizer-ecommerce.
the class ProductOptionFacadeImpl method getAttributesList.
@Override
public ReadableProductAttributeList getAttributesList(Long productId, MerchantStore store, Language language) {
try {
Product product = this.product(productId, store);
List<ProductAttribute> attributes = null;
if (language != null) {
attributes = productAttributeService.getByProductId(store, product, language);
} else {
attributes = productAttributeService.getByProductId(store, product);
}
ReadableProductAttributeList attrList = new ReadableProductAttributeList();
attrList.setRecordsTotal(attributes.size());
attrList.setNumber(attributes.size());
List<ReadableProductAttributeEntity> values = attributes.stream().map(attribute -> readableProductAttributeMapper.convert(attribute, store, language)).collect(Collectors.toList());
attrList.setAttributes(values);
return attrList;
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while getting attributes", e);
}
}
Aggregations