This is my intial problem that I can't solve:
I am trying to modify my category structure as part of creating a new shop with Porto and Magento 2.
My products were migrated to m2 from m1 using the Migration Tool.
I have been deleting categories and creating new ones. That has worked fine. However, now I am trying to allocate products to new categories I am facing errors that say:
"The value specified in the URL Key field would generate a URL that already exists."
I have tried various fixes, such as:
I have read various issues concerning use of URL Keys and rewrite rules but nobody seems to have a definitive answer. My problem is the same as the one referenced here:
It would be great if someone had a definitive answer to how to fix this error as my categories will not work unless I can get this fixed.
I am also thinking about this as an alternative:
The old categories and new categories could all be deleted. I don't have a properly live website yet. Could I:
- remove all products from all categories
- delete all categories
- delete all "product" entity rows in the url_rewrite table in M2 database
- create new categories and add products without the url rewrite errors
If the above is possible could I just remove all the products from all the categories and then delete all "product" entity rows in the url_rewrite table?
I would be most grateful for any assistance here as I am completely stuck!
Thanks in advance.
Doesn't anyone have any leads on what to do here? I am completely stuck.
You might be better off truncating the URL_Rewrite table and installing https://github.com/olegkoval/magento2-regenerate_url_rewrites
Then regenerate all the URL rewrites back into the database.
This has been a major headache for after the migration and althrough I can see where the error is with regards to duplicate URL's the only decent option is to start over
you can install "Regenerate Url rewrites" extension by
composer require olegkoval/magento2-regenerate-url-rewrites
enable the extension
php bin/magento module:enable OlegKoval_RegenerateUrlRewrites
now you can use this extension to regenerate by the following command
php bin/magento ok:urlrewrites:regenerate
there are many options available for this extension you can check here
Hi Amit,
Thanks for your reply - it is most appreciated!
I had come across this module but what didn't seem clear to me was whether this was written predominently for an earlier M2 version and therefore whether or not it is compatible with version M2.3, with me knowing M2 has seen some significant changes from earlier versions.
If this module is indeed compatible then it sounds like it will be a good idea to install it and try to fix these annoying url rewrite issues..... Are you sure it is compatible? I only ask as I don't want to render my M2 system unusable for any period as I run my live stock control from it :-)
This is compatible with 2.3 and 2.4 so that you know
Would truncating the table be a redundant process if you install the module? I'd assume the module would delete current URL rewrites and then insert new ones?
As I mentioned in the previous reply to Amit - I don't want to do something rash and find it is broken, even if I back everything up beforehand and then have to restore. The latter would cause an outage and I'd like to be pretty confident implementing a change will work before tackling it head on :-)
The truncate gives you a clean start.
What gets left behind by using the module is the redirects, so it's easier to truncate and start a fresh.
yes, it works with M2.3,
FYI
this module deletes all entries from URL rewrite table and regenerate and insert new data in the tables.
it's very useful.
Do I truncate the WHOLE url_writes table or just specific rows?