Skip to content

Commit

Permalink
Merge pull request #75 from erfanimani/improve-error-message
Browse files Browse the repository at this point in the history
Improved product URL error message to show which URLs were not unique
  • Loading branch information
peterjaap authored Dec 14, 2022
2 parents 9c6a82d + df95734 commit 5911c9f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Service/RegenerateProductUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ public function execute(?array $productIds = null, ?int $storeId = null, bool $v
if (count($newUrls)) {
$regeneratedForStore += $this->replaceUrls($newUrls, true);
}
} catch (\Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException $e) {
$this->log(sprintf(
'<error>Couldn\'t insert duplicate URL rewrites for the following ' .
'products on store ID %d (current batch failed):' . PHP_EOL . '%s</error>',
$store->getId(),
implode(PHP_EOL, array_map(function ($url) {
return sprintf(
'- Product ID: %d, request path: %s',
$url['entity_id'],
$url['request_path']
);
}, $e->getUrls()))
));
} catch (Exception $e) {
$this->log(
sprintf(
Expand Down

0 comments on commit 5911c9f

Please sign in to comment.