Search in sources :

Example 1 with ProductOptionValueDescription

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

the class ProductNextGenTest method createOptions.

/**
 * Add possible choices
 * @param product
 * @throws Exception
 */
private void createOptions(Product product) throws Exception {
    /**
     * An attribute can be created dynamicaly but the attached Option and Option value need to exist
     */
    MerchantStore store = product.getMerchantStore();
    Language en = languageService.getByCode("en");
    /**
     * Create size option
     */
    size = new ProductOption();
    size.setMerchantStore(store);
    size.setCode("SHOESIZE");
    size.setProductOptionType(ProductOptionType.Radio.name());
    ProductOptionDescription sizeDescription = new ProductOptionDescription();
    sizeDescription.setLanguage(en);
    sizeDescription.setName("Size");
    sizeDescription.setDescription("Show size");
    sizeDescription.setProductOption(size);
    size.getDescriptions().add(sizeDescription);
    // create option
    productOptionService.saveOrUpdate(size);
    /**
     * Create size values (9, 9.5, 10)
     */
    // option value 9
    nine = new ProductOptionValue();
    nine.setMerchantStore(store);
    nine.setCode("nine");
    ProductOptionValueDescription nineDescription = new ProductOptionValueDescription();
    nineDescription.setLanguage(en);
    nineDescription.setName("9");
    nineDescription.setDescription("Size 9");
    nineDescription.setProductOptionValue(nine);
    nine.getDescriptions().add(nineDescription);
    // create an option value
    productOptionValueService.saveOrUpdate(nine);
    // option value 9.5
    nineHalf = new ProductOptionValue();
    nineHalf.setMerchantStore(store);
    nineHalf.setCode("nineHalf");
    ProductOptionValueDescription nineHalfDescription = new ProductOptionValueDescription();
    nineHalfDescription.setLanguage(en);
    nineHalfDescription.setName("9.5");
    nineHalfDescription.setDescription("Size 9.5");
    nineHalfDescription.setProductOptionValue(nineHalf);
    nineHalf.getDescriptions().add(nineHalfDescription);
    // create an option value
    productOptionValueService.saveOrUpdate(nineHalf);
    // option value 10
    ten = new ProductOptionValue();
    ten.setMerchantStore(store);
    ten.setCode("ten");
    ProductOptionValueDescription tenDescription = new ProductOptionValueDescription();
    tenDescription.setLanguage(en);
    tenDescription.setName("10");
    tenDescription.setDescription("Size 10");
    tenDescription.setProductOptionValue(ten);
    ten.getDescriptions().add(tenDescription);
    // create an option value
    productOptionValueService.saveOrUpdate(ten);
// end options / options values
}
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) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Example 2 with ProductOptionValueDescription

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

the class ProductTest method testAttributes.

private void testAttributes(Product product) throws Exception {
    /**
     * An attribute can be created dynamicaly but the attached Option and Option value need to exist
     */
    MerchantStore store = product.getMerchantStore();
    Language en = languageService.getByCode("en");
    /**
     * Create size option
     */
    ProductOption color = new ProductOption();
    color.setMerchantStore(store);
    color.setCode("COLOR");
    color.setProductOptionType(ProductOptionType.Radio.name());
    ProductOptionDescription optionDescription = new ProductOptionDescription();
    optionDescription.setLanguage(en);
    optionDescription.setName("Color");
    optionDescription.setDescription("Color of an item");
    optionDescription.setProductOption(color);
    color.getDescriptions().add(optionDescription);
    // create option
    productOptionService.saveOrUpdate(color);
    /**
     * Create size option
     */
    ProductOption size = new ProductOption();
    size.setMerchantStore(store);
    size.setCode("SIZE");
    size.setProductOptionType(ProductOptionType.Radio.name());
    ProductOptionDescription sizeDescription = new ProductOptionDescription();
    sizeDescription.setLanguage(en);
    sizeDescription.setName("Size");
    sizeDescription.setDescription("Size of an item");
    sizeDescription.setProductOption(size);
    size.getDescriptions().add(sizeDescription);
    // create option
    productOptionService.saveOrUpdate(size);
    // option value
    ProductOptionValue red = new ProductOptionValue();
    red.setMerchantStore(store);
    red.setCode("red");
    ProductOptionValueDescription redDescription = new ProductOptionValueDescription();
    redDescription.setLanguage(en);
    redDescription.setName("Red");
    redDescription.setDescription("Red color");
    redDescription.setProductOptionValue(red);
    red.getDescriptions().add(redDescription);
    // create an option value
    productOptionValueService.saveOrUpdate(red);
    // another option value
    ProductOptionValue blue = new ProductOptionValue();
    blue.setMerchantStore(store);
    blue.setCode("blue");
    ProductOptionValueDescription blueDescription = new ProductOptionValueDescription();
    blueDescription.setLanguage(en);
    blueDescription.setName("Blue");
    blueDescription.setDescription("Color blue");
    blueDescription.setProductOptionValue(blue);
    blue.getDescriptions().add(blueDescription);
    // create another option value
    productOptionValueService.saveOrUpdate(blue);
    // option value
    ProductOptionValue small = new ProductOptionValue();
    small.setMerchantStore(store);
    small.setCode("small");
    ProductOptionValueDescription smallDescription = new ProductOptionValueDescription();
    smallDescription.setLanguage(en);
    smallDescription.setName("Small");
    smallDescription.setDescription("Small size");
    smallDescription.setProductOptionValue(small);
    small.getDescriptions().add(smallDescription);
    // create an option value
    productOptionValueService.saveOrUpdate(small);
    // another option value
    ProductOptionValue medium = new ProductOptionValue();
    medium.setMerchantStore(store);
    medium.setCode("medium");
    ProductOptionValueDescription mediumDescription = new ProductOptionValueDescription();
    mediumDescription.setLanguage(en);
    mediumDescription.setName("Medium");
    mediumDescription.setDescription("Medium size");
    mediumDescription.setProductOptionValue(medium);
    medium.getDescriptions().add(mediumDescription);
    // create another option value
    productOptionValueService.saveOrUpdate(medium);
    ProductAttribute color_blue = new ProductAttribute();
    color_blue.setProduct(product);
    color_blue.setProductOption(color);
    color_blue.setAttributeDefault(true);
    // no price variation
    color_blue.setProductAttributePrice(new BigDecimal(0));
    // weight variation
    color_blue.setProductAttributeWeight(new BigDecimal(1));
    color_blue.setProductOptionValue(blue);
    productAttributeService.create(color_blue);
    product.getAttributes().add(color_blue);
    /**
     * create attributes *
     */
    // attributes
    ProductAttribute color_red = new ProductAttribute();
    color_red.setProduct(product);
    color_red.setProductOption(color);
    color_red.setAttributeDefault(true);
    // no price variation
    color_red.setProductAttributePrice(new BigDecimal(0));
    // weight variation
    color_red.setProductAttributeWeight(new BigDecimal(1));
    color_red.setProductOptionValue(red);
    productAttributeService.create(color_red);
    product.getAttributes().add(color_red);
    ProductAttribute smallAttr = new ProductAttribute();
    smallAttr.setProduct(product);
    smallAttr.setProductOption(size);
    smallAttr.setAttributeDefault(true);
    // no price variation
    smallAttr.setProductAttributePrice(new BigDecimal(0));
    // weight variation
    smallAttr.setProductAttributeWeight(new BigDecimal(1));
    smallAttr.setProductOptionValue(small);
    productAttributeService.create(smallAttr);
    product.getAttributes().add(smallAttr);
    productService.update(product);
    /**
     * get options facets
     */
    List<ProductAttribute> attributes = productAttributeService.getProductAttributesByCategoryLineage(store, product.getCategories().iterator().next().getLineage(), en);
    Assert.assertTrue((long) attributes.size() > 0);
}
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) Language(com.salesmanager.core.model.reference.language.Language) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) BigDecimal(java.math.BigDecimal) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Example 3 with ProductOptionValueDescription

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

the class ReadableProductVariationMapper method optionValue.

private ReadableProductOptionValue optionValue(ProductOptionValue val, MerchantStore store, Language language) {
    ReadableProductOptionValue value = new ReadableProductOptionValue();
    value.setCode(val.getCode());
    value.setId(val.getId());
    ProductOptionValueDescription desc = optionValueDescription(val.getDescriptions(), language);
    if (desc != null) {
        value.setName(desc.getName());
    }
    return value;
}
Also used : ReadableProductOptionValue(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductOptionValue) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Example 4 with ProductOptionValueDescription

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

the class CategoryFacadeImpl method categoryProductVariants.

@Override
public List<ReadableProductVariant> categoryProductVariants(Long categoryId, MerchantStore store, Language language) {
    Category category = categoryService.getById(categoryId, store.getId());
    List<ReadableProductVariant> variants = new ArrayList<ReadableProductVariant>();
    if (category == null) {
        throw new ResourceNotFoundException("Category [" + categoryId + "] not found");
    }
    try {
        List<ProductAttribute> attributes = productAttributeService.getProductAttributesByCategoryLineage(store, category.getLineage(), language);
        /**
         * Option NAME OptionValueName OptionValueName
         */
        Map<String, List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue>> rawFacet = new HashMap<String, List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue>>();
        Map<String, ProductOption> references = new HashMap<String, ProductOption>();
        for (ProductAttribute attr : attributes) {
            references.put(attr.getProductOption().getCode(), attr.getProductOption());
            List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue> values = rawFacet.get(attr.getProductOption().getCode());
            if (values == null) {
                values = new ArrayList<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue>();
                rawFacet.put(attr.getProductOption().getCode(), values);
            }
            if (attr.getProductOptionValue() != null) {
                Optional<ProductOptionValueDescription> desc = attr.getProductOptionValue().getDescriptions().stream().filter(o -> o.getLanguage().getId() == language.getId()).findFirst();
                com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue val = new com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue();
                val.setCode(attr.getProductOption().getCode());
                String order = attr.getAttributeSortOrder();
                val.setSortOrder(order == null ? attr.getId().intValue() : Integer.parseInt(attr.getAttributeSortOrder()));
                if (desc.isPresent()) {
                    val.setName(desc.get().getName());
                } else {
                    val.setName(attr.getProductOption().getCode());
                }
                values.add(val);
            }
        }
        // for each reference set Option
        Iterator<Entry<String, ProductOption>> it = references.entrySet().iterator();
        while (it.hasNext()) {
            @SuppressWarnings("rawtypes") Map.Entry pair = (Map.Entry) it.next();
            ProductOption option = (ProductOption) pair.getValue();
            List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue> values = rawFacet.get(option.getCode());
            ReadableProductVariant productVariant = new ReadableProductVariant();
            Optional<ProductOptionDescription> optionDescription = option.getDescriptions().stream().filter(o -> o.getLanguage().getId() == language.getId()).findFirst();
            if (optionDescription.isPresent()) {
                productVariant.setName(optionDescription.get().getName());
                productVariant.setId(optionDescription.get().getId());
                productVariant.setCode(optionDescription.get().getProductOption().getCode());
                List<ReadableProductVariantValue> optionValues = new ArrayList<ReadableProductVariantValue>();
                for (com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValue value : values) {
                    ReadableProductVariantValue v = new ReadableProductVariantValue();
                    v.setCode(value.getCode());
                    v.setName(value.getName());
                    v.setDescription(value.getName());
                    v.setOption(option.getId());
                    v.setValue(value.getId());
                    v.setOrder(option.getProductOptionSortOrder());
                    optionValues.add(v);
                }
                Comparator<ReadableProductVariantValue> orderComparator = Comparator.comparingInt(ReadableProductVariantValue::getOrder);
                // Arrays.sort(employees, employeeSalaryComparator);
                List<ReadableProductVariantValue> readableValues = optionValues.stream().sorted(orderComparator).collect(Collectors.toList());
                // sort by name
                // remove duplicates
                readableValues = optionValues.stream().distinct().collect(Collectors.toList());
                readableValues.sort(Comparator.comparing(ReadableProductVariantValue::getName));
                productVariant.setOptions(readableValues);
                variants.add(productVariant);
            }
        }
        return variants;
    } catch (Exception e) {
        throw new ServiceRuntimeException("An error occured while retrieving ProductAttributes", e);
    }
}
Also used : CategoryFacade(com.salesmanager.shop.store.controller.category.facade.CategoryFacade) PersistableCategoryPopulator(com.salesmanager.shop.populator.catalog.PersistableCategoryPopulator) HashMap(java.util.HashMap) ReadableProductVariantValue(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductVariantValue) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ServiceException(com.salesmanager.core.business.exception.ServiceException) Inject(javax.inject.Inject) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription) Language(com.salesmanager.core.model.reference.language.Language) ListCriteria(com.salesmanager.shop.model.entity.ListCriteria) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) Map(java.util.Map) ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) ReadableProductVariant(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductVariant) ReadableCategoryPopulator(com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator) CategoryService(com.salesmanager.core.business.services.catalog.category.CategoryService) MerchantStoreService(com.salesmanager.core.business.services.merchant.MerchantStoreService) ProductAttributeService(com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Mapper(com.salesmanager.shop.mapper.Mapper) Iterator(java.util.Iterator) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) Collectors(java.util.stream.Collectors) ReadableCategoryList(com.salesmanager.shop.model.catalog.category.ReadableCategoryList) UnauthorizedException(com.salesmanager.shop.store.api.exception.UnauthorizedException) Objects(java.util.Objects) Category(com.salesmanager.core.model.catalog.category.Category) List(java.util.List) Validate(org.apache.commons.lang3.Validate) CollectionUtils(org.springframework.util.CollectionUtils) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ReadableCategory(com.salesmanager.shop.model.catalog.category.ReadableCategory) Entry(java.util.Map.Entry) Optional(java.util.Optional) ConversionException(com.salesmanager.core.business.exception.ConversionException) Comparator(java.util.Comparator) PersistableCategory(com.salesmanager.shop.model.catalog.category.PersistableCategory) Entry(java.util.Map.Entry) Category(com.salesmanager.core.model.catalog.category.Category) ReadableCategory(com.salesmanager.shop.model.catalog.category.ReadableCategory) PersistableCategory(com.salesmanager.shop.model.catalog.category.PersistableCategory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) ReadableCategoryList(com.salesmanager.shop.model.catalog.category.ReadableCategoryList) List(java.util.List) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) ReadableProductVariant(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductVariant) ServiceException(com.salesmanager.core.business.exception.ServiceException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) UnauthorizedException(com.salesmanager.shop.store.api.exception.UnauthorizedException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionException(com.salesmanager.core.business.exception.ConversionException) HashMap(java.util.HashMap) Map(java.util.Map) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription) ReadableProductVariantValue(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductVariantValue)

Example 5 with ProductOptionValueDescription

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

the class ShoppingCartDataPopulator method populate.

@Override
public ShoppingCartData populate(final ShoppingCart shoppingCart, final ShoppingCartData cart, final MerchantStore store, final Language language) {
    Validate.notNull(shoppingCart, "Requires ShoppingCart");
    Validate.notNull(language, "Requires Language not null");
    int cartQuantity = 0;
    cart.setCode(shoppingCart.getShoppingCartCode());
    Set<com.salesmanager.core.model.shoppingcart.ShoppingCartItem> items = shoppingCart.getLineItems();
    List<ShoppingCartItem> shoppingCartItemsList = Collections.emptyList();
    try {
        if (items != null) {
            shoppingCartItemsList = new ArrayList<ShoppingCartItem>();
            for (com.salesmanager.core.model.shoppingcart.ShoppingCartItem item : items) {
                ShoppingCartItem shoppingCartItem = new ShoppingCartItem();
                shoppingCartItem.setCode(cart.getCode());
                shoppingCartItem.setProductCode(item.getProduct().getSku());
                shoppingCartItem.setProductVirtual(item.isProductVirtual());
                shoppingCartItem.setProductId(item.getProductId());
                shoppingCartItem.setId(item.getId());
                String itemName = item.getProduct().getProductDescription().getName();
                if (!CollectionUtils.isEmpty(item.getProduct().getDescriptions())) {
                    for (ProductDescription productDescription : item.getProduct().getDescriptions()) {
                        if (language != null && language.getId().intValue() == productDescription.getLanguage().getId().intValue()) {
                            itemName = productDescription.getName();
                            break;
                        }
                    }
                }
                shoppingCartItem.setName(itemName);
                shoppingCartItem.setPrice(pricingService.getDisplayAmount(item.getItemPrice(), store));
                shoppingCartItem.setQuantity(item.getQuantity());
                cartQuantity = cartQuantity + item.getQuantity();
                shoppingCartItem.setProductPrice(item.getItemPrice());
                shoppingCartItem.setSubTotal(pricingService.getDisplayAmount(item.getSubTotal(), store));
                ProductImage image = item.getProduct().getProductImage();
                if (image != null && imageUtils != null) {
                    String imagePath = imageUtils.buildProductImageUtils(store, item.getProduct().getSku(), image.getProductImage());
                    shoppingCartItem.setImage(imagePath);
                }
                Set<com.salesmanager.core.model.shoppingcart.ShoppingCartAttributeItem> attributes = item.getAttributes();
                if (attributes != null) {
                    List<ShoppingCartAttribute> cartAttributes = new ArrayList<ShoppingCartAttribute>();
                    for (com.salesmanager.core.model.shoppingcart.ShoppingCartAttributeItem attribute : attributes) {
                        ShoppingCartAttribute cartAttribute = new ShoppingCartAttribute();
                        cartAttribute.setId(attribute.getId());
                        cartAttribute.setAttributeId(attribute.getProductAttributeId());
                        cartAttribute.setOptionId(attribute.getProductAttribute().getProductOption().getId());
                        cartAttribute.setOptionValueId(attribute.getProductAttribute().getProductOptionValue().getId());
                        List<ProductOptionDescription> optionDescriptions = attribute.getProductAttribute().getProductOption().getDescriptionsSettoList();
                        List<ProductOptionValueDescription> optionValueDescriptions = attribute.getProductAttribute().getProductOptionValue().getDescriptionsSettoList();
                        if (!CollectionUtils.isEmpty(optionDescriptions) && !CollectionUtils.isEmpty(optionValueDescriptions)) {
                            String optionName = optionDescriptions.get(0).getName();
                            String optionValue = optionValueDescriptions.get(0).getName();
                            for (ProductOptionDescription optionDescription : optionDescriptions) {
                                if (optionDescription.getLanguage() != null && optionDescription.getLanguage().getId().intValue() == language.getId().intValue()) {
                                    optionName = optionDescription.getName();
                                    break;
                                }
                            }
                            for (ProductOptionValueDescription optionValueDescription : optionValueDescriptions) {
                                if (optionValueDescription.getLanguage() != null && optionValueDescription.getLanguage().getId().intValue() == language.getId().intValue()) {
                                    optionValue = optionValueDescription.getName();
                                    break;
                                }
                            }
                            cartAttribute.setOptionName(optionName);
                            cartAttribute.setOptionValue(optionValue);
                            cartAttributes.add(cartAttribute);
                        }
                    }
                    shoppingCartItem.setShoppingCartAttributes(cartAttributes);
                }
                shoppingCartItemsList.add(shoppingCartItem);
            }
        }
        if (CollectionUtils.isNotEmpty(shoppingCartItemsList)) {
            cart.setShoppingCartItems(shoppingCartItemsList);
        }
        if (shoppingCart.getOrderId() != null) {
            cart.setOrderId(shoppingCart.getOrderId());
        }
        OrderSummary summary = new OrderSummary();
        List<com.salesmanager.core.model.shoppingcart.ShoppingCartItem> productsList = new ArrayList<com.salesmanager.core.model.shoppingcart.ShoppingCartItem>();
        productsList.addAll(shoppingCart.getLineItems());
        summary.setProducts(productsList.stream().filter(p -> p.getProduct().isAvailable()).collect(Collectors.toList()));
        OrderTotalSummary orderSummary = shoppingCartCalculationService.calculate(shoppingCart, store, language);
        if (CollectionUtils.isNotEmpty(orderSummary.getTotals())) {
            List<OrderTotal> totals = new ArrayList<OrderTotal>();
            for (com.salesmanager.core.model.order.OrderTotal t : orderSummary.getTotals()) {
                OrderTotal total = new OrderTotal();
                total.setCode(t.getOrderTotalCode());
                total.setText(t.getText());
                total.setValue(t.getValue());
                totals.add(total);
            }
            cart.setTotals(totals);
        }
        cart.setSubTotal(pricingService.getDisplayAmount(orderSummary.getSubTotal(), store));
        cart.setTotal(pricingService.getDisplayAmount(orderSummary.getTotal(), store));
        cart.setQuantity(cartQuantity);
        cart.setId(shoppingCart.getId());
    } catch (ServiceException ex) {
        LOG.error("Error while converting cart Model to cart Data.." + ex);
        throw new ConversionException("Unable to create cart data", ex);
    }
    return cart;
}
Also used : ProductImage(com.salesmanager.core.model.catalog.product.image.ProductImage) OrderSummary(com.salesmanager.core.model.order.OrderSummary) OrderTotalSummary(com.salesmanager.core.model.order.OrderTotalSummary) ArrayList(java.util.ArrayList) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) ShoppingCartAttribute(com.salesmanager.shop.model.shoppingcart.ShoppingCartAttribute) ConversionException(org.apache.commons.beanutils.ConversionException) ServiceException(com.salesmanager.core.business.exception.ServiceException) ShoppingCartItem(com.salesmanager.shop.model.shoppingcart.ShoppingCartItem) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription) OrderTotal(com.salesmanager.shop.model.order.total.OrderTotal) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Aggregations

ProductOptionValueDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)18 ProductOptionDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription)12 ProductOptionValue (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue)10 ProductAttribute (com.salesmanager.core.model.catalog.product.attribute.ProductAttribute)9 Language (com.salesmanager.core.model.reference.language.Language)9 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)8 ProductOption (com.salesmanager.core.model.catalog.product.attribute.ProductOption)7 ArrayList (java.util.ArrayList)7 Category (com.salesmanager.core.model.catalog.category.Category)5 Product (com.salesmanager.core.model.catalog.product.Product)5 ProductDescription (com.salesmanager.core.model.catalog.product.description.ProductDescription)5 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)4 ProductPrice (com.salesmanager.core.model.catalog.product.price.ProductPrice)4 ProductPriceDescription (com.salesmanager.core.model.catalog.product.price.ProductPriceDescription)4 ReadableProductProperty (com.salesmanager.shop.model.catalog.product.attribute.ReadableProductProperty)4 ReadableProductPropertyValue (com.salesmanager.shop.model.catalog.product.attribute.ReadableProductPropertyValue)4 BigDecimal (java.math.BigDecimal)4 ProductImage (com.salesmanager.core.model.catalog.product.image.ProductImage)3 ManufacturerDescription (com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription)3 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)3