Skip to content

Commit

Permalink
move error handling for duplicated urls to replce URLS method to prev…
Browse files Browse the repository at this point in the history
…ent failing entire store URL regenration
  • Loading branch information
Gerke committed Jul 24, 2024
1 parent 859253f commit 9fd6c90
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Service/RegenerateProductUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,17 @@ private function log(string $message): void
private function replaceUrls(array &$urls, bool $last = false): int
{
$this->log(sprintf('replaceUrls%s batch: %d', $last ? ' last' : '', count($urls)));
$this->urlPersist->replace($urls);

foreach ($urls as $url) {
try {
$this->urlPersist->replace([$url]);
} catch (UrlAlreadyExistsException $e) {
$this->log(sprintf($e->getMessage(). ' Entity id: %d Request path: %s',
$url->getEntityId(),
$url->getRequestPath()
));
}
}
$count = count($urls);
$urls = [];

Expand Down

0 comments on commit 9fd6c90

Please sign in to comment.