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.");
}
}
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;
}
Aggregations