diff --git a/prototype/src/main/java/org/hso/ecommerce/action/cronjob/UpdateOffersAction.java b/prototype/src/main/java/org/hso/ecommerce/action/cronjob/UpdateOffersAction.java index 3046f2f..f095381 100644 --- a/prototype/src/main/java/org/hso/ecommerce/action/cronjob/UpdateOffersAction.java +++ b/prototype/src/main/java/org/hso/ecommerce/action/cronjob/UpdateOffersAction.java @@ -29,6 +29,12 @@ public class UpdateOffersAction { public List finish() { HashMap availableOffers = mapOffers(); + + // Reset all advertise-flags first. They are set again below. + for (ArticleOffer offer : availableOffers.values()) { + offer.shouldBeAdvertised = false; + } + for (Entry cheapestOffer : cheapestOffer.entrySet()) { String manufacturer = cheapestOffer.getKey().manufacturer; String articleNumber = cheapestOffer.getKey().articleNumber; @@ -42,7 +48,11 @@ public class UpdateOffersAction { Article currentOfferedArticle = cheapestOffer.getValue().apiSupplier.findArticle(manufacturer, articleNumber); currentOffer.vatPercent = currentOfferedArticle.vatPercent; - currentOffer.shouldBeAdvertised = currentOfferedArticle.shouldBeAdvertised; + + // Set advertise-flag if any supplier wants it to be set + if (currentOfferedArticle.shouldBeAdvertised) { + currentOffer.shouldBeAdvertised = true; + } } return offers; }