Search in sources :

Example 1 with PromotableProduct

use of org.broadleafcommerce.core.catalog.domain.PromotableProduct in project BroadleafCommerce by BroadleafCommerce.

the class RelatedProductsServiceImpl method findRelatedProducts.

@Override
public List<? extends PromotableProduct> findRelatedProducts(RelatedProductDTO relatedProductDTO) {
    Product product = lookupProduct(relatedProductDTO);
    Category category = lookupCategory(relatedProductDTO);
    if (RelatedProductTypeEnum.FEATURED.equals(relatedProductDTO.getType())) {
        return buildFeaturedProductsList(product, category, relatedProductDTO);
    } else if (RelatedProductTypeEnum.CROSS_SALE.equals(relatedProductDTO.getType())) {
        return buildCrossSaleProductsList(product, category, relatedProductDTO);
    } else if (RelatedProductTypeEnum.UP_SALE.equals(relatedProductDTO.getType())) {
        return buildUpSaleProductsList(product, category, relatedProductDTO);
    } else {
        throw new IllegalArgumentException("RelatedProductType " + relatedProductDTO.getType() + " not supported.");
    }
}
Also used : Category(org.broadleafcommerce.core.catalog.domain.Category) FeaturedProduct(org.broadleafcommerce.core.catalog.domain.FeaturedProduct) Product(org.broadleafcommerce.core.catalog.domain.Product) PromotableProduct(org.broadleafcommerce.core.catalog.domain.PromotableProduct)

Example 2 with PromotableProduct

use of org.broadleafcommerce.core.catalog.domain.PromotableProduct in project BroadleafCommerce by BroadleafCommerce.

the class RelatedProductsServiceImpl method removeDuplicatesFromList.

private List<? extends PromotableProduct> removeDuplicatesFromList(List<? extends PromotableProduct> returnPromotableProducts) {
    Set<PromotableProduct> productSet = new LinkedHashSet<PromotableProduct>();
    Set<Product> relatedProductSet = new LinkedHashSet<Product>();
    if (returnPromotableProducts != null) {
        for (PromotableProduct p : returnPromotableProducts) {
            if (!relatedProductSet.contains(p.getRelatedProduct())) {
                productSet.add(p);
                relatedProductSet.add(p.getRelatedProduct());
            }
        }
    } else {
        return null;
    }
    returnPromotableProducts.clear();
    returnPromotableProducts.addAll(new ArrayList(productSet));
    return returnPromotableProducts;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) FeaturedProduct(org.broadleafcommerce.core.catalog.domain.FeaturedProduct) Product(org.broadleafcommerce.core.catalog.domain.Product) PromotableProduct(org.broadleafcommerce.core.catalog.domain.PromotableProduct) PromotableProduct(org.broadleafcommerce.core.catalog.domain.PromotableProduct)

Aggregations

FeaturedProduct (org.broadleafcommerce.core.catalog.domain.FeaturedProduct)2 Product (org.broadleafcommerce.core.catalog.domain.Product)2 PromotableProduct (org.broadleafcommerce.core.catalog.domain.PromotableProduct)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Category (org.broadleafcommerce.core.catalog.domain.Category)1