URL key for specified store already exists.

Hi,
 
When I saving some of categories or moving them, it gives an error  URL key for specified store already exists. Please advise me how to fix this.
 
Many Thanks,
Sam

34 answers

Profile photo of Mall Staff 184060.00 $tone August 9, 2017
Public

Hi there,

URL key for specified store already exists

I’m sorry that is a issue of Magento 2 core with your data migrated from a old system (Magento 1). You could view more about it at this post.
Also, Can you tell me how many categories with that issue in your Magento 2 instance now?
Let’s provide me the admin credentials, ssh credentials and web root path of your Magento 2. And specify me some categories IDs with issue as you mentioned. I will check further and try apply some tweak code to help you out.
Regards,
Mall.

#1
Profile photo of ssleftfield 190.00 $tone August 10, 2017
Public

If you still getting the error, can you run pagent.exe file (This is a tool comes with putty package), There you will need to add the private key while you are connecting on winscp. Please let me know if you still having issues to connect.
Kind Regards,
Sam

#8
Profile photo of Mall Staff 184060.00 $tone August 13, 2017
Public

Hi there,
I still can’t access your server via SSH now. Let’s try do steps as followings:
-- Download the php file at FILE 1
and upload to to path: app/code/Ubertheme/Ubdatamigration/Model/ProductUrlRewriteGenerator.php
-- Download the php file at FILE 2
and upload to the path: app/code/Ubertheme/Ubdatamigration/Model/Product/AnchorUrlRewriteGenerator.php
-- Download the XML file at FILE 3
and upload to the path: app/code/Ubertheme/Ubdatamigration/etc/di.xml
Once done, let’s re-compile your Magento2 and clean Magento cached.
And recheck the issues as you mentioned. And tell me know how it goes.
Regards,
Mall.

#12
Profile photo of Mall Staff 184060.00 $tone August 16, 2017
Public

Hi there,

. Do you think any other effects changing this file for other modules otr functionalities?

What version of your Magento2 instance in your working now? That is core module of Magento. Our tool does not overwrite for that php file. I still can’t open a ssh connection to your server now, therefore i don’t know about other module which can effect to that file.
Regards,
Mall.
 

#18
Profile photo of Mall Staff 184060.00 $tone August 17, 2017
Public

Hi there,
Yeah, let’s continue with your Magento2 instance at your end and contact me if you need further assistance.

I have updated \vendor\magento\module-url-rewrite\Model\Storage\DbStorage.php file and issue has been fixed. Do you think any other effects changing this file for other modules otr functionalities?

You should view this post to clear more about that: https://mage2.pro/t/topic/4238/3
Regards,
Mall.

#20
Profile photo of ssleftfield 190.00 $tone August 17, 2017
Public

Hi Mall,
 
Thank you, so far no problem found with my changes to that file. Will continue my work and get back to you for any assitance required.
Thank you very much.
Sam

#21
Profile photo of ssleftfield 190.00 $tone August 28, 2017
Public

Hi Mall,
 
When I try to save a category, again it shows error “Something went wrong while saving the category.” . I found detail error in the exception log. Please advise .
[2017-08-28 10:35:10] main.CRITICAL: Exception: Warning: Declaration of Ubertheme\Ubdatamigration\Model\ProductUrlRewriteGenerator::generateForGlobalScope($productCategories) should be compatible with Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::generateForGlobalScope($productCategories, $product = NULL, $rootCategoryId = NULL) in /opt/bitnami/apps/magento/htdocs/app/code/Ubertheme/Ubdatamigration/Model/ProductUrlRewriteGenerator.php on line 0 in /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 /opt/bitnami/apps/magento/htdocs/vendor/composer/ClassLoader.php(412): Magento\Framework\App\ErrorHandler->handler(2, ‘Declaration of …’, ‘/opt/bitnami/ap…’, 0, Array)
#1 /opt/bitnami/apps/magento/htdocs/vendor/composer/ClassLoader.php(412): include()
#2 /opt/bitnami/apps/magento/htdocs/vendor/composer/ClassLoader.php(301): Composer\Autoload\includeFile(‘/opt/bitnami/ap…’)
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass(‘Ubertheme\\Ubdat…’)
#4 [internal function]: spl_autoload_call(‘Ubertheme\\Ubdat…’)
#5 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Relations/Runtime.php(38): class_exists(‘Ubertheme\\Ubdat…’)
#6 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Config/Config.php(153): Magento\Framework\ObjectManager\Relations\Runtime->has(‘Ubertheme\\Ubdat…’)
#7 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Config/Config.php(176): Magento\Framework\Interception\Config\Config->_inheritInterception(‘Ubertheme\\Ubdat…’)
#8 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/ObjectManager/Config/Developer.php(61): Magento\Framework\Interception\Config\Config->hasPlugins(‘Ubertheme\\Ubdat…’)
#9 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(70): Magento\Framework\Interception\ObjectManager\Config\Developer->getInstanceType(‘Ubertheme\\Ubdat…’)
#10 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create(‘Ubertheme\\Ubdat…’)
#11 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get(‘Ubertheme\\Ubdat…’)
#12 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, ‘Magento\\Catalog…’, NULL, ‘productUrlRewri…’, ‘Magento\\Catalog…’)
#13 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments(‘Magento\\Catalog…’, Array, Array)
#14 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create(‘Magento\\Catalog…’)
#15 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(126): Magento\Framework\ObjectManager\ObjectManager->get(‘Magento\\Catalog…’)
#16 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, ‘Magento\\Catalog…’, NULL, ‘urlRewriteHandl…’, ‘Magento\\Catalog…’)
#17 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments(‘Magento\\Catalog…’, Array, Array)
#18 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create(‘Magento\\Catalog…’)
#19 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/ObserverFactory.php(33): Magento\Framework\ObjectManager\ObjectManager->get(‘Magento\\Catalog…’)
#20 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php(59): Magento\Framework\Event\ObserverFactory->get(‘Magento\\Catalog…’)
#21 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#22 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch(‘catalog_categor…’, Array)
#23 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php(802): Magento\Framework\Event\Manager\Proxy->dispatch(‘catalog_categor…’, Array)
#24 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog/Model/Category.php(1080): Magento\Framework\Model\AbstractModel->afterSave()
#25 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Catalog/Model/Category/Interceptor.php(583): Magento\Catalog\Model\Category->afterSave()
#26 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/EntityManager/Observer/AfterEntitySave.php(34): Magento\Catalog\Model\Category\Interceptor->afterSave()
#27 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php(73): Magento\Framework\EntityManager\Observer\AfterEntitySave->execute(Object(Magento\Framework\Event\Observer))
#28 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php(61): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Framework\EntityManager\Observer\AfterEntitySave), Object(Magento\Framework\Event\Observer))
#29 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#30 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch(‘magento_catalog…’, Array)
#31 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/EntityManager/EventManager.php(51): Magento\Framework\Event\Manager\Proxy->dispatch(‘magento_catalog…’, Array)
#32 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/EntityManager/Operation/Update.php(108): Magento\Framework\EntityManager\EventManager->dispatchEntityEvent(‘Magento\\Catalog…’, ‘save_after’, Array)
#33 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/EntityManager/EntityManager.php(87): Magento\Framework\EntityManager\Operation\Update->execute(Object(Magento\Catalog\Model\Category\Interceptor), Array)
#34 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog/Model/ResourceModel/Category.php(1041): Magento\Framework\EntityManager\EntityManager->save(Object(Magento\Catalog\Model\Category\Interceptor))
#35 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Catalog\Model\ResourceModel\Category->save(Object(Magento\Catalog\Model\Category\Interceptor))
#36 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callParent(‘save’, Array)
#37 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext(‘Magento\\Catalog…’, ‘save’, Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, ‘catalogsearchFu…’)
#38 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(43): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#39 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(29): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->addCommitCallback(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#40 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#41 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext(‘Magento\\Catalog…’, ‘save’, Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, ‘clean_cache’)
#42 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/Cache/FlushCacheByTags.php(71): Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#43 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#44 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Catalog/Model/ResourceModel/Category/Interceptor.php(364): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callPlugins(‘save’, Array, Array)
#45 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php(631): Magento\Catalog\Model\ResourceModel\Category\Interceptor->save(Object(Magento\Catalog\Model\Category\Interceptor))
#46 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Model\AbstractModel->save()
#47 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Catalog/Model/Category/Interceptor.php(1534): Magento\Catalog\Model\Category\Interceptor->___callPlugins(‘save’, Array, Array)
#48 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-catalog/Controller/Adminhtml/Category/Save.php(212): Magento\Catalog\Model\Category\Interceptor->save()
#49 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(24): Magento\Catalog\Controller\Adminhtml\Category\Save->execute()
#50 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/Action/Action.php(102): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->execute()
#51 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#52 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#53 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callParent(‘dispatch’, Array)
#54 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext(‘Magento\\Catalog…’, ‘dispatch’, Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, ‘adminAuthentica…’)
#55 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#56 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#57 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext(‘Magento\\Catalog…’, ‘dispatch’, Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, ‘adminMassaction…’)
#58 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#59 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#60 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(65): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callPlugins(‘dispatch’, Array, Array)
#61 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#62 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#63 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent(‘dispatch’, Array)
#64 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext(‘Magento\\Framewo…’, ‘dispatch’, Object(Magento\Framework\App\FrontController\Interceptor), Array, ‘install’)
#65 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#66 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#67 /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins(‘dispatch’, Array, Array)
#68 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#69 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#70 /opt/bitnami/apps/magento/htdocs/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#71 {main} [] []

#23
Profile photo of Mall Staff 184060.00 $tone August 28, 2017
Public

Hi there,

[2017-08-28 10:35:10] main.CRITICAL: Exception: Warning: Declaration of Ubertheme\Ubdatamigration\Model\ProductUrlRewriteGenerator::generateForGlobalScope($productCategories) should be compatible with 

To solve that issue, you could do steps as followings:

  • Download the XML file at HERE
  • And upload downloaded file to the file at app/code/Ubertheme/Ubdatamigration/etc/di.xml
  • Once done, clean the Magento 2 cache. 

Regards,
Mall.

#24
Profile photo of Mall Staff 184060.00 $tone September 1, 2017
Public

Hi there,

When I try to save the category show this errror.
http://vvcap.com/zMSF6Ux3bGj

That is a issue of Magento’s core with your migrated data in some categories. The root issue related to some value of the url_path field in some categories migrated. Also, you could try with steps as followings:
Step 1: Run cli command: php -f bin/ubdatamigration fixduplicateurl 
Step 2: Re-save the categories which has issue as you mentioned.
And tell me know how it goes.
Regards,
Mall.

#28
Profile photo of Mall Staff 184060.00 $tone September 3, 2017
Public

Hi there,
Seem your MySQL is ver.5.7.x To solve that issue, you could re-setting your MySQL to disable the setting ONLY_FULL_GROUP_BY as guide in this post.
Once done, you can continue with steps as my suggesting in reply #28
And tell me know how it goes.
Regards,
Mall.

#30
Profile photo of ubdev Staff 98150.00 $tone December 19, 2017
Public

Hi Marcin, 
Thanks for sharing the workaround with us. 
We will take further consideration into this, anyway we always try our best not to modify Magento core though. 
Best, 
Ubertheme team.

#34

Please login or Register to Submit Answer

Written By

Comments