I am facing "URL key for specified store already exists" error when i am trying to update existing category name as its appearing in some categories.
I am using Magento 2.1.4.
I have read so many articles where it stated that it is solved in magento 2.1 version but its appearing again. Let me know
FYI I'm using multi-store
Please help me to resolve the issue.
Thanks
Hello
This is happening on Magento 2.1.7. I have installed this trough XAMPP and I don't consider these to be good solutions at all as they might affect Magento data in the future.
How come this is not fixed. What can we do?
This is happening to me with a Default Category and 2 Sub categories (Subcategory 1 and Subcategory 2) and only 2 products (Product 1 and Product 2) which I want to add to Subcategory 1 and Subcategory 2 respectively.
Of course all URL keys are unique. What's going on? Shouldn't Magento team fix this?
Thanks
I did following changes and it is working.
Magento\UrlRewrite\Model\Storage\DbStorage.php file
protected function insertMultiple($data) { try { $keys=array(); foreach($data as $current=>$_data) { $key = $_data['request_path']; if(in_array($key,$keys)) { unset($data[$current]); }else { $keys[]=$key; } } $this->connection->insertMultiple($this->resource->getTableName(self::TABLE_NAME), $data); } catch (\Exception $e) { if ($e->getCode() === self::ERROR_CODE_DUPLICATE_ENTRY && preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\d]#', $e->getMessage()) ) { throw new \Magento\Framework\Exception\AlreadyExistsException( __('URL key for specified store already exists.') ); } throw $e; } }
Hope it will help you.
Hello
I appreciate your help as I saw many people proposing different solutions and one of them was this. However is this an approved solution? Will it cause trouble in the future? I mean, this is even happening with 2 categories and 2 products only!!!
Is there an explanation of this happens? As it seems not everyone has this issue..
Thanks
i did that code and it is working fine for me.
Hi
I am not indicating it doesn't work. i am just asking if it's a recommended solution at all. Changing core code could cause problems in the future. That's why I ask. So I wonder if there's a proposed solution by Magento, or if they are even aware of it.
Magento team still not provide solution for that, meantime you can use this solution. whenever they provide update then readme file and remove this code.
Hope you can understand.
Thank you Sunil
@Sunil Patel this solution does't working for me, As I'm using multi-website with 5 website and more then 30K products.