delete products
This commit is contained in:
parent
f57eb9e924
commit
a719e83ce7
|
|
@ -86,16 +86,25 @@ public class ProductSyncService {
|
||||||
if (!dolibarrSkus.contains(mapping.getSku()) && mapping.getPrestashopId() != null) {
|
if (!dolibarrSkus.contains(mapping.getSku()) && mapping.getPrestashopId() != null) {
|
||||||
try {
|
try {
|
||||||
prestashopClient.deleteProduct(mapping.getPrestashopId());
|
prestashopClient.deleteProduct(mapping.getPrestashopId());
|
||||||
|
} catch (PrestashopApiException e) {
|
||||||
|
if (e.getStatusCode() != null && e.getStatusCode().value() == 404) {
|
||||||
|
log.debug("ProductSync: PS product already gone SKU={} psId={}", mapping.getSku(), mapping.getPrestashopId());
|
||||||
|
} else {
|
||||||
|
failed++;
|
||||||
|
errors.add("Delete SKU %s: %s".formatted(mapping.getSku(), e.getMessage()));
|
||||||
|
log.warn("ProductSync delete failed SKU={}: {}", mapping.getSku(), e.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (RestClientException | HttpMessageConversionException e) {
|
||||||
|
failed++;
|
||||||
|
errors.add("Delete SKU %s: %s".formatted(mapping.getSku(), e.getMessage()));
|
||||||
|
log.warn("ProductSync delete failed SKU={}: {}", mapping.getSku(), e.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
productMappingRepository.delete(mapping);
|
productMappingRepository.delete(mapping);
|
||||||
processed++;
|
processed++;
|
||||||
log.info("ProductSync: deleted PS product SKU={} psId={} (no longer in Dolibarr)",
|
log.info("ProductSync: deleted PS product SKU={} psId={} (no longer in Dolibarr)",
|
||||||
mapping.getSku(), mapping.getPrestashopId());
|
mapping.getSku(), mapping.getPrestashopId());
|
||||||
} catch (PrestashopApiException | RestClientException | HttpMessageConversionException e) {
|
|
||||||
failed++;
|
|
||||||
String msg = "Delete SKU %s: %s".formatted(mapping.getSku(), e.getMessage());
|
|
||||||
errors.add(msg);
|
|
||||||
log.warn("ProductSync delete failed: {}", msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue