Search in sources :

Example 16 with ProductOption

use of com.salesmanager.core.model.catalog.product.attribute.ProductOption in project shopizer by shopizer-ecommerce.

the class CatalogServiceHelper method setToLanguage.

/**
 * Filters descriptions and set the appropriate language
 * @param p
 * @param language
 */
public static void setToLanguage(Product p, int language) {
    Set<ProductAttribute> attributes = p.getAttributes();
    if (attributes != null) {
        for (ProductAttribute attribute : attributes) {
            ProductOption po = attribute.getProductOption();
            Set<ProductOptionDescription> spod = po.getDescriptions();
            if (spod != null) {
                Set<ProductOptionDescription> podDescriptions = new HashSet<ProductOptionDescription>();
                for (ProductOptionDescription pod : spod) {
                    // System.out.println("    ProductOptionDescription : " + pod.getProductOptionName());
                    if (pod.getLanguage().getId() == language) {
                        podDescriptions.add(pod);
                    }
                }
                po.setDescriptions(podDescriptions);
            }
            ProductOptionValue pov = attribute.getProductOptionValue();
            Set<ProductOptionValueDescription> spovd = pov.getDescriptions();
            if (spovd != null) {
                Set<ProductOptionValueDescription> povdDescriptions = new HashSet<>();
                for (ProductOptionValueDescription povd : spovd) {
                    if (povd.getLanguage().getId() == language) {
                        povdDescriptions.add(povd);
                    }
                }
                pov.setDescriptions(povdDescriptions);
            }
        }
    }
}
Also used : ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) HashSet(java.util.HashSet) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Aggregations

ProductOption (com.salesmanager.core.model.catalog.product.attribute.ProductOption)16 ProductOptionValue (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue)10 ProductAttribute (com.salesmanager.core.model.catalog.product.attribute.ProductAttribute)8 ProductOptionDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription)8 ProductOptionValueDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)7 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)7 Language (com.salesmanager.core.model.reference.language.Language)7 ServiceException (com.salesmanager.core.business.exception.ServiceException)5 Product (com.salesmanager.core.model.catalog.product.Product)4 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)4 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)4 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)4 BigDecimal (java.math.BigDecimal)4 HashSet (java.util.HashSet)4 Category (com.salesmanager.core.model.catalog.category.Category)3 ProductType (com.salesmanager.core.model.catalog.product.type.ProductType)3 Date (java.util.Date)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ProductAttributeService (com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService)2