Search in sources :

Example 1 with ProductPrice

use of com.salesmanager.core.model.catalog.product.price.ProductPrice in project shopizer by shopizer-ecommerce.

the class ProductFacadeImpl method updateProductPrice.

@Override
public ReadableProduct updateProductPrice(ReadableProduct product, ProductPriceEntity price, Language language) throws Exception {
    Product persistable = productService.getById(product.getId());
    if (persistable == null) {
        throw new Exception("product is null for id " + product.getId());
    }
    java.util.Set<ProductAvailability> availabilities = persistable.getAvailabilities();
    for (ProductAvailability availability : availabilities) {
        ProductPrice productPrice = availability.defaultPrice();
        productPrice.setProductPriceAmount(price.getOriginalPrice());
        if (price.isDiscounted()) {
            productPrice.setProductPriceSpecialAmount(price.getDiscountedPrice());
            if (!StringUtils.isBlank(price.getDiscountStartDate())) {
                Date startDate = DateUtil.getDate(price.getDiscountStartDate());
                productPrice.setProductPriceSpecialStartDate(startDate);
            }
            if (!StringUtils.isBlank(price.getDiscountEndDate())) {
                Date endDate = DateUtil.getDate(price.getDiscountEndDate());
                productPrice.setProductPriceSpecialEndDate(endDate);
            }
        }
    }
    productService.update(persistable);
    ReadableProduct readableProduct = new ReadableProduct();
    ReadableProductPopulator populator = new ReadableProductPopulator();
    populator.setPricingService(pricingService);
    populator.setimageUtils(imageUtils);
    populator.populate(persistable, readableProduct, persistable.getMerchantStore(), language);
    return readableProduct;
}
Also used : ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ReadableProductPopulator(com.salesmanager.shop.populator.catalog.ReadableProductPopulator) PersistableProduct(com.salesmanager.shop.model.catalog.product.PersistableProduct) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) Product(com.salesmanager.core.model.catalog.product.Product) LightPersistableProduct(com.salesmanager.shop.model.catalog.product.LightPersistableProduct) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) ReadableProductPrice(com.salesmanager.shop.model.catalog.product.ReadableProductPrice) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) ServiceException(com.salesmanager.core.business.exception.ServiceException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) Date(java.util.Date)

Example 2 with ProductPrice

use of com.salesmanager.core.model.catalog.product.price.ProductPrice in project shopizer by shopizer-ecommerce.

the class PersistableProductDefinitionMapper method merge.

@Override
public Product merge(PersistableProductDefinition source, Product destination, MerchantStore store, Language language) {
    Validate.notNull(destination, "Product must not be null");
    try {
        destination.setSku(source.getIdentifier());
        destination.setAvailable(source.isVisible());
        destination.setDateAvailable(new Date());
        destination.setRefSku(source.getIdentifier());
        if (source.getId() != null && source.getId().longValue() == 0) {
            destination.setId(null);
        } else {
            destination.setId(source.getId());
        }
        // MANUFACTURER
        if (!StringUtils.isBlank(source.getManufacturer())) {
            Manufacturer manufacturer = manufacturerService.getByCode(store, source.getManufacturer());
            if (manufacturer == null) {
                throw new ConversionException("Manufacturer [" + source.getManufacturer() + "] does not exist");
            }
            destination.setManufacturer(manufacturer);
        }
        // PRODUCT TYPE
        if (!StringUtils.isBlank(source.getType())) {
            ProductType type = productTypeService.getByCode(source.getType(), store, language);
            if (type == null) {
                throw new ConversionException("Product type [" + source.getType() + "] does not exist");
            }
            destination.setType(type);
        }
        if (!StringUtils.isBlank(source.getDateAvailable())) {
            destination.setDateAvailable(DateUtil.getDate(source.getDateAvailable()));
        }
        destination.setMerchantStore(store);
        List<Language> languages = new ArrayList<Language>();
        Set<ProductDescription> descriptions = new HashSet<ProductDescription>();
        if (!CollectionUtils.isEmpty(source.getDescriptions())) {
            for (com.salesmanager.shop.model.catalog.product.ProductDescription description : source.getDescriptions()) {
                ProductDescription productDescription = new ProductDescription();
                Language lang = languageService.getByCode(description.getLanguage());
                if (lang == null) {
                    throw new ConversionException("Language code " + description.getLanguage() + " is invalid, use ISO code (en, fr ...)");
                }
                if (!CollectionUtils.isEmpty(destination.getDescriptions())) {
                    for (ProductDescription desc : destination.getDescriptions()) {
                        if (desc.getLanguage().getCode().equals(description.getLanguage())) {
                            productDescription = desc;
                            break;
                        }
                    }
                }
                productDescription.setProduct(destination);
                productDescription.setDescription(description.getDescription());
                productDescription.setProductHighlight(description.getHighlights());
                productDescription.setName(description.getName());
                productDescription.setSeUrl(description.getFriendlyUrl());
                productDescription.setMetatagKeywords(description.getKeyWords());
                productDescription.setMetatagDescription(description.getMetaDescription());
                productDescription.setTitle(description.getTitle());
                languages.add(lang);
                productDescription.setLanguage(lang);
                descriptions.add(productDescription);
            }
        }
        if (descriptions.size() > 0) {
            destination.setDescriptions(descriptions);
        }
        // if(source.getRating() != null) {
        // destination.setProductReviewAvg(new BigDecimal(source.getRating()));
        // }
        // destination.setProductReviewCount(source.getRatingCount());
        /**
         * Product definition
         */
        ProductAvailability productAvailability = null;
        ProductPrice defaultPrice = null;
        if (!CollectionUtils.isEmpty(destination.getAvailabilities())) {
            for (ProductAvailability avail : destination.getAvailabilities()) {
                Set<ProductPrice> prices = avail.getPrices();
                for (ProductPrice p : prices) {
                    if (p.isDefaultPrice()) {
                        if (productAvailability == null) {
                            productAvailability = avail;
                            defaultPrice = p;
                            productAvailability.setProductQuantity(source.getQuantity());
                            productAvailability.setProductStatus(source.isCanBePurchased());
                            p.setProductPriceAmount(source.getPrice());
                            break;
                        }
                    }
                }
            }
        }
        if (productAvailability == null) {
            // create with default values
            productAvailability = new ProductAvailability(destination, store);
            destination.getAvailabilities().add(productAvailability);
            productAvailability.setProductQuantity(source.getQuantity());
            productAvailability.setProductQuantityOrderMin(1);
            productAvailability.setProductQuantityOrderMax(1);
            productAvailability.setRegion(Constants.ALL_REGIONS);
            productAvailability.setAvailable(Boolean.valueOf(destination.isAvailable()));
            productAvailability.setProductStatus(source.isCanBePurchased());
        }
        if (defaultPrice == null) {
            defaultPrice = new ProductPrice();
            defaultPrice.setDefaultPrice(true);
            defaultPrice.setProductPriceAmount(source.getPrice());
            defaultPrice.setCode(ProductPriceEntity.DEFAULT_PRICE_CODE);
            defaultPrice.setProductAvailability(productAvailability);
            productAvailability.getPrices().add(defaultPrice);
            for (Language lang : languages) {
                ProductPriceDescription ppd = new ProductPriceDescription();
                ppd.setProductPrice(defaultPrice);
                ppd.setLanguage(lang);
                ppd.setName(ProductPriceDescription.DEFAULT_PRICE_DESCRIPTION);
                defaultPrice.getDescriptions().add(ppd);
            }
        }
        if (source.getProductSpecifications() != null) {
            destination.setProductHeight(source.getProductSpecifications().getHeight());
            destination.setProductLength(source.getProductSpecifications().getLength());
            destination.setProductWeight(source.getProductSpecifications().getWeight());
            destination.setProductWidth(source.getProductSpecifications().getWidth());
            if (source.getProductSpecifications().getManufacturer() != null) {
                Manufacturer manuf = null;
                if (!StringUtils.isBlank(source.getProductSpecifications().getManufacturer())) {
                    manuf = manufacturerService.getByCode(store, source.getProductSpecifications().getManufacturer());
                }
                if (manuf == null) {
                    throw new ConversionException("Invalid manufacturer id");
                }
                if (manuf != null) {
                    if (manuf.getMerchantStore().getId().intValue() != store.getId().intValue()) {
                        throw new ConversionException("Invalid manufacturer id");
                    }
                    destination.setManufacturer(manuf);
                }
            }
        }
        destination.setSortOrder(source.getSortOrder());
        destination.setProductVirtual(source.isVirtual());
        destination.setProductShipeable(source.isShipeable());
        // attributes
        if (source.getProperties() != null) {
            for (com.salesmanager.shop.model.catalog.product.attribute.PersistableProductAttribute attr : source.getProperties()) {
                ProductAttribute attribute = persistableProductAttributeMapper.convert(attr, store, language);
                attribute.setProduct(destination);
                destination.getAttributes().add(attribute);
            }
        }
        // categories
        if (!CollectionUtils.isEmpty(source.getCategories())) {
            for (com.salesmanager.shop.model.catalog.category.Category categ : source.getCategories()) {
                Category c = null;
                if (!StringUtils.isBlank(categ.getCode())) {
                    c = categoryService.getByCode(store, categ.getCode());
                } else {
                    Validate.notNull(categ.getId(), "Category id nust not be null");
                    c = categoryService.getById(categ.getId(), store.getId());
                }
                if (c == null) {
                    throw new ConversionException("Category id " + categ.getId() + " does not exist");
                }
                if (c.getMerchantStore().getId().intValue() != store.getId().intValue()) {
                    throw new ConversionException("Invalid category id");
                }
                destination.getCategories().add(c);
            }
        }
        return destination;
    } catch (Exception e) {
        throw new ConversionRuntimeException("Error converting product mapper", e);
    }
}
Also used : Category(com.salesmanager.core.model.catalog.category.Category) ArrayList(java.util.ArrayList) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Language(com.salesmanager.core.model.reference.language.Language) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) Manufacturer(com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer) ProductPriceDescription(com.salesmanager.core.model.catalog.product.price.ProductPriceDescription) HashSet(java.util.HashSet) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ConversionException(com.salesmanager.core.business.exception.ConversionException) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) Date(java.util.Date) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ConversionException(com.salesmanager.core.business.exception.ConversionException) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription)

Example 3 with ProductPrice

use of com.salesmanager.core.model.catalog.product.price.ProductPrice in project shopizer by shopizer-ecommerce.

the class ShippingQuoteByWeightTest method testGetCustomShippingQuotesByWeight.

@Ignore
public // @Test
void testGetCustomShippingQuotesByWeight() throws ServiceException {
    Language en = languageService.getByCode("en");
    Country country = countryService.getByCode("CA");
    Zone zone = zoneService.getByCode("QC");
    MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
    ProductType generalType = productTypeService.getProductType(ProductType.GENERAL_TYPE);
    // set valid store postal code
    store.setStorepostalcode("J4B-9J9");
    Product product = new Product();
    product.setProductHeight(new BigDecimal(4));
    product.setProductLength(new BigDecimal(3));
    product.setProductWidth(new BigDecimal(5));
    product.setProductWeight(new BigDecimal(8));
    product.setSku("TESTSKU");
    product.setType(generalType);
    product.setMerchantStore(store);
    // Product description
    ProductDescription description = new ProductDescription();
    description.setName("Product 1");
    description.setLanguage(en);
    description.setProduct(product);
    product.getDescriptions().add(description);
    productService.create(product);
    // productService.saveOrUpdate(product);
    // Availability
    ProductAvailability availability = new ProductAvailability();
    availability.setProductDateAvailable(new Date());
    availability.setProductQuantity(100);
    availability.setRegion("*");
    // associate with product
    availability.setProduct(product);
    product.getAvailabilities().add(availability);
    productAvailabilityService.create(availability);
    ProductPrice dprice = new ProductPrice();
    dprice.setDefaultPrice(true);
    dprice.setProductPriceAmount(new BigDecimal(29.99));
    dprice.setProductAvailability(availability);
    ProductPriceDescription dpd = new ProductPriceDescription();
    dpd.setName("Base price");
    dpd.setProductPrice(dprice);
    dpd.setLanguage(en);
    dprice.getDescriptions().add(dpd);
    availability.getPrices().add(dprice);
    productPriceService.create(dprice);
    // get product
    product = productService.getByCode("TESTSKU", en);
    // check the product
    Set<ProductAvailability> avails = product.getAvailabilities();
    for (ProductAvailability as : avails) {
        Set<ProductPrice> availabilityPrices = as.getPrices();
        for (ProductPrice ps : availabilityPrices) {
            System.out.println(ps.getProductPriceAmount().toString());
        }
    }
    // check availability
    Set<ProductPrice> availabilityPrices = availability.getPrices();
    for (ProductPrice ps : availabilityPrices) {
        System.out.println(ps.getProductPriceAmount().toString());
    }
    // configure shipping
    ShippingConfiguration shippingConfiguration = new ShippingConfiguration();
    // based on shipping or billing address
    shippingConfiguration.setShippingBasisType(ShippingBasisType.SHIPPING);
    shippingConfiguration.setShippingType(ShippingType.INTERNATIONAL);
    // individual item pricing or box packaging (see unit test above)
    shippingConfiguration.setShippingPackageType(ShippingPackageType.ITEM);
    // only if package type is package
    shippingConfiguration.setBoxHeight(5);
    shippingConfiguration.setBoxLength(5);
    shippingConfiguration.setBoxWidth(5);
    shippingConfiguration.setBoxWeight(1);
    shippingConfiguration.setMaxWeight(10);
    List<String> supportedCountries = new ArrayList<String>();
    supportedCountries.add("CA");
    supportedCountries.add("US");
    supportedCountries.add("UK");
    supportedCountries.add("FR");
    shippingService.setSupportedCountries(store, supportedCountries);
    CustomShippingQuotesConfiguration customConfiguration = new CustomShippingQuotesConfiguration();
    customConfiguration.setModuleCode("weightBased");
    customConfiguration.setActive(true);
    CustomShippingQuotesRegion northRegion = new CustomShippingQuotesRegion();
    northRegion.setCustomRegionName("NORTH");
    List<String> countries = new ArrayList<String>();
    countries.add("CA");
    countries.add("US");
    northRegion.setCountries(countries);
    CustomShippingQuoteWeightItem caQuote4 = new CustomShippingQuoteWeightItem();
    caQuote4.setMaximumWeight(4);
    caQuote4.setPrice(new BigDecimal(20));
    CustomShippingQuoteWeightItem caQuote10 = new CustomShippingQuoteWeightItem();
    caQuote10.setMaximumWeight(10);
    caQuote10.setPrice(new BigDecimal(50));
    CustomShippingQuoteWeightItem caQuote100 = new CustomShippingQuoteWeightItem();
    caQuote100.setMaximumWeight(100);
    caQuote100.setPrice(new BigDecimal(120));
    List<CustomShippingQuoteWeightItem> quotes = new ArrayList<CustomShippingQuoteWeightItem>();
    quotes.add(caQuote4);
    quotes.add(caQuote10);
    quotes.add(caQuote100);
    northRegion.setQuoteItems(quotes);
    customConfiguration.getRegions().add(northRegion);
    // create an integration configuration - USPS
    IntegrationConfiguration configuration = new IntegrationConfiguration();
    configuration.setActive(true);
    configuration.setEnvironment(Environment.TEST.name());
    configuration.setModuleCode("weightBased");
    // configure module
    shippingService.saveShippingConfiguration(shippingConfiguration, store);
    // create the basic configuration
    shippingService.saveShippingQuoteModuleConfiguration(configuration, store);
    // and the custom configuration
    shippingService.saveCustomShippingConfiguration("weightBased", customConfiguration, store);
    // now create ShippingProduct
    ShippingProduct shippingProduct1 = new ShippingProduct(product);
    FinalPrice price = pricingService.calculateProductPrice(product);
    shippingProduct1.setFinalPrice(price);
    List<ShippingProduct> shippingProducts = new ArrayList<ShippingProduct>();
    shippingProducts.add(shippingProduct1);
    Customer customer = new Customer();
    customer.setMerchantStore(store);
    customer.setEmailAddress("test@test.com");
    customer.setGender(CustomerGender.M);
    customer.setDefaultLanguage(en);
    customer.setAnonymous(true);
    customer.setCompany("ifactory");
    customer.setDateOfBirth(new Date());
    customer.setNick("My nick");
    customer.setPassword("123456");
    Delivery delivery = new Delivery();
    delivery.setAddress("Shipping address");
    delivery.setCity("Boucherville");
    delivery.setCountry(country);
    delivery.setZone(zone);
    delivery.setPostalCode("J5C-6J4");
    // overwrite delivery to US
    /*	    delivery.setPostalCode("90002");
	    delivery.setCountry(us);
	    Zone california = zoneService.getByCode("CA");
	    delivery.setZone(california);*/
    Billing billing = new Billing();
    billing.setAddress("Billing address");
    billing.setCountry(country);
    billing.setZone(zone);
    billing.setPostalCode("J4B-8J9");
    billing.setFirstName("Carl");
    billing.setLastName("Samson");
    customer.setBilling(billing);
    customer.setDelivery(delivery);
    customerService.create(customer);
    // for correlation
    Long dummyCartId = 0L;
    ShippingQuote shippingQuote = shippingService.getShippingQuote(dummyCartId, store, delivery, shippingProducts, en);
    Assert.notNull(shippingQuote);
}
Also used : Customer(com.salesmanager.core.model.customer.Customer) ArrayList(java.util.ArrayList) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Product(com.salesmanager.core.model.catalog.product.Product) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) ShippingConfiguration(com.salesmanager.core.model.shipping.ShippingConfiguration) Language(com.salesmanager.core.model.reference.language.Language) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) CustomShippingQuoteWeightItem(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuoteWeightItem) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ProductPriceDescription(com.salesmanager.core.model.catalog.product.price.ProductPriceDescription) FinalPrice(com.salesmanager.core.model.catalog.product.price.FinalPrice) CustomShippingQuotesConfiguration(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuotesConfiguration) Zone(com.salesmanager.core.model.reference.zone.Zone) CustomShippingQuotesRegion(com.salesmanager.core.modules.integration.shipping.model.CustomShippingQuotesRegion) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) BigDecimal(java.math.BigDecimal) Date(java.util.Date) ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) Billing(com.salesmanager.core.model.common.Billing) Country(com.salesmanager.core.model.reference.country.Country) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription) Delivery(com.salesmanager.core.model.common.Delivery) Ignore(org.junit.Ignore)

Example 4 with ProductPrice

use of com.salesmanager.core.model.catalog.product.price.ProductPrice in project shopizer by shopizer-ecommerce.

the class ProductTest method testCreateRelationShip.

private void testCreateRelationShip(Product product) throws Exception {
    MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
    Language en = languageService.getByCode("en");
    Manufacturer oreilley = manufacturerService.getByCode(store, "oreilley");
    ProductType generalType = productTypeService.getProductType(ProductType.GENERAL_TYPE);
    Category tech = categoryService.getByCode(store, "tech");
    // create new related product
    // PRODUCT 1
    Product related = new Product();
    related.setProductHeight(new BigDecimal(4));
    related.setProductLength(new BigDecimal(3));
    related.setProductWidth(new BigDecimal(1));
    related.setSku("TB67891");
    related.setManufacturer(oreilley);
    related.setType(generalType);
    related.setMerchantStore(store);
    // Product description
    ProductDescription description = new ProductDescription();
    description.setName("Spring 4 in Action");
    description.setLanguage(en);
    description.setProduct(related);
    product.getDescriptions().add(description);
    // add category
    product.getCategories().add(tech);
    // Availability
    ProductAvailability availability = new ProductAvailability();
    availability.setProductDateAvailable(date);
    availability.setProductQuantity(200);
    availability.setRegion("*");
    // associate with product
    availability.setProduct(related);
    // productAvailabilityService.create(availability);
    related.getAvailabilities().add(availability);
    ProductPrice dprice = new ProductPrice();
    dprice.setDefaultPrice(true);
    dprice.setProductPriceAmount(new BigDecimal(39.99));
    dprice.setProductAvailability(availability);
    ProductPriceDescription dpd = new ProductPriceDescription();
    dpd.setName("Base price");
    dpd.setProductPrice(dprice);
    dpd.setLanguage(en);
    dprice.getDescriptions().add(dpd);
    availability.getPrices().add(dprice);
    related.getAvailabilities().add(availability);
    productService.save(related);
    ProductRelationship relationship = new ProductRelationship();
    relationship.setActive(true);
    relationship.setCode("spring");
    relationship.setProduct(product);
    relationship.setRelatedProduct(related);
    relationship.setStore(store);
    // because relationships are nor joined fetched, make sure you query relationships first, then ad to an existing list
    // so relationship and review are they only objects not joined fetch when querying a product
    // need to do a subsequent query
    List<ProductRelationship> relationships = productRelationshipService.listByProduct(product);
    relationships.add(relationship);
    product.setRelationships(new HashSet<ProductRelationship>(relationships));
    productService.save(product);
}
Also used : Category(com.salesmanager.core.model.catalog.category.Category) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) Product(com.salesmanager.core.model.catalog.product.Product) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) BigDecimal(java.math.BigDecimal) Language(com.salesmanager.core.model.reference.language.Language) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ProductRelationship(com.salesmanager.core.model.catalog.product.relationship.ProductRelationship) Manufacturer(com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ProductPriceDescription(com.salesmanager.core.model.catalog.product.price.ProductPriceDescription)

Example 5 with ProductPrice

use of com.salesmanager.core.model.catalog.product.price.ProductPrice in project shopizer by shopizer-ecommerce.

the class ProductPriceUtils method calculateFinalPrice.

private FinalPrice calculateFinalPrice(Product product) {
    FinalPrice finalPrice = null;
    List<FinalPrice> otherPrices = null;
    Set<ProductAvailability> availabilities = product.getAvailabilities();
    for (ProductAvailability availability : availabilities) {
        if (!StringUtils.isEmpty(availability.getRegion()) && availability.getRegion().equals(Constants.ALL_REGIONS)) {
            // TODO REL 2.1 accept a region
            Set<ProductPrice> prices = availability.getPrices();
            for (ProductPrice price : prices) {
                FinalPrice p = finalPrice(price);
                if (price.isDefaultPrice()) {
                    finalPrice = p;
                } else {
                    if (otherPrices == null) {
                        otherPrices = new ArrayList<FinalPrice>();
                    }
                    otherPrices.add(p);
                }
            }
        }
    }
    if (finalPrice != null) {
        finalPrice.setAdditionalPrices(otherPrices);
    } else {
        if (otherPrices != null) {
            finalPrice = otherPrices.get(0);
        }
    }
    return finalPrice;
}
Also used : ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) FinalPrice(com.salesmanager.core.model.catalog.product.price.FinalPrice)

Aggregations

ProductPrice (com.salesmanager.core.model.catalog.product.price.ProductPrice)20 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)17 Product (com.salesmanager.core.model.catalog.product.Product)12 ProductPriceDescription (com.salesmanager.core.model.catalog.product.price.ProductPriceDescription)12 Language (com.salesmanager.core.model.reference.language.Language)11 ProductDescription (com.salesmanager.core.model.catalog.product.description.ProductDescription)10 Category (com.salesmanager.core.model.catalog.category.Category)9 ProductType (com.salesmanager.core.model.catalog.product.type.ProductType)9 Date (java.util.Date)9 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)8 BigDecimal (java.math.BigDecimal)8 ArrayList (java.util.ArrayList)8 ProductAttribute (com.salesmanager.core.model.catalog.product.attribute.ProductAttribute)7 Manufacturer (com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer)7 HashSet (java.util.HashSet)7 ConversionException (com.salesmanager.core.business.exception.ConversionException)6 ServiceException (com.salesmanager.core.business.exception.ServiceException)5 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)5 PersistableProduct (com.salesmanager.shop.model.catalog.product.PersistableProduct)5 ReadableProduct (com.salesmanager.shop.model.catalog.product.ReadableProduct)5