Search in sources :

Example 1 with ReadableProductOptionFull

use of com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionFull in project shopizer by shopizer-ecommerce.

the class ReadableProductOptionMapper method merge.

@Override
public ReadableProductOptionEntity merge(ProductOption source, ReadableProductOptionEntity destination, MerchantStore store, Language language) {
    ReadableProductOptionEntity readableProductOption = new ReadableProductOptionEntity();
    if (language == null) {
        readableProductOption = new ReadableProductOptionFull();
        List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionDescription> descriptions = new ArrayList<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionDescription>();
        for (ProductOptionDescription desc : source.getDescriptions()) {
            com.salesmanager.shop.model.catalog.product.attribute.ProductOptionDescription d = this.description(desc);
            descriptions.add(d);
        }
        ((ReadableProductOptionFull) readableProductOption).setDescriptions(descriptions);
    } else {
        readableProductOption = new ReadableProductOptionEntity();
        if (!CollectionUtils.isEmpty(source.getDescriptions())) {
            for (ProductOptionDescription desc : source.getDescriptions()) {
                if (desc != null && desc.getLanguage() != null && desc.getLanguage().getId() == language.getId()) {
                    com.salesmanager.shop.model.catalog.product.attribute.ProductOptionDescription d = this.description(desc);
                    readableProductOption.setDescription(d);
                }
            }
        }
    }
    readableProductOption.setCode(source.getCode());
    readableProductOption.setId(source.getId());
    readableProductOption.setType(source.getProductOptionType());
    return readableProductOption;
}
Also used : ReadableProductOptionFull(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionFull) ArrayList(java.util.ArrayList) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) ReadableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity)

Aggregations

ProductOptionDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription)1 ReadableProductOptionEntity (com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity)1 ReadableProductOptionFull (com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionFull)1 ArrayList (java.util.ArrayList)1