Created
June 9, 2017 17:53
-
-
Save erikhansen/0fce448d642012814ff8fb1bd37ed4ea to your computer and use it in GitHub Desktop.
Patch to see what is causing the "URL key for specified store already exists" error when saving entities in Magento 2. This patch should only be temporarily applied and needs to be applied to the vendor/magento/module-url-rewrite directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3523dd79d949f93e31fc675b190f17baf66f36c3 Mon Sep 17 00:00:00 2001 | |
From: Erik Hansen <[email protected]> | |
Date: Wed, 1 Feb 2017 13:20:02 -0600 | |
Subject: [PATCH] Edit the 'URL key for specified store already exists' message | |
--- | |
Model/Storage/AbstractStorage.php | 5 ++++- | |
Model/Storage/DbStorage.php | 5 ++++- | |
2 files changed, 8 insertions(+), 2 deletions(-) | |
diff --git a/Model/Storage/AbstractStorage.php b/Model/Storage/AbstractStorage.php | |
index 9a57d29..dd58f4d 100644 | |
--- a/Model/Storage/AbstractStorage.php | |
+++ b/Model/Storage/AbstractStorage.php | |
@@ -83,7 +83,10 @@ abstract class AbstractStorage implements StorageInterface | |
$this->doReplace($urls); | |
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) { | |
throw new \Magento\Framework\Exception\AlreadyExistsException( | |
- __('URL key for specified store already exists.') | |
+ // BEGIN EDIT | |
+ // To assist in troubleshooting "URL key for specified store already exists", show first 2000 characters of exception message | |
+ __('URL key for specified store already exists.' . ' - ' . substr($e->getMessage(), 0, 2000)) | |
+ // END EDIT | |
); | |
} | |
} | |
diff --git a/Model/Storage/DbStorage.php b/Model/Storage/DbStorage.php | |
index 9ef1364..2dd57a7 100644 | |
--- a/Model/Storage/DbStorage.php | |
+++ b/Model/Storage/DbStorage.php | |
@@ -114,7 +114,10 @@ class DbStorage extends AbstractStorage | |
&& preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\d]#', $e->getMessage()) | |
) { | |
throw new \Magento\Framework\Exception\AlreadyExistsException( | |
- __('URL key for specified store already exists.') | |
+ // BEGIN EDIT | |
+ // To assist in troubleshooting "URL key for specified store already exists", show first 2000 characters of exception message | |
+ __('URL key for specified store already exists.' . ' - ' . substr($e->getMessage(), 0, 2000)) | |
+ // END EDIT | |
); | |
} | |
throw $e; | |
-- | |
2.5.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment