How to resolve issue Could not save product with position to category? How to regenerate url rewrites in products and categories of magento 2 totally?

Its best solution!!! working ok, tested on magento 2.3.5-p1

- Go to `Stores > Settings > Configuration` in the menu - Go to the `Catalog > Catalog` section - Go to the `Search Engine Optimization` tab - Set `Create Permanent Redirect for URLs if URL Key Changed` to `No`

later will back to yes.

https://github.com/elgentos/regenerate-catalog-urls

bin/magento regenerate:product:url

 

=====

How to resolve issue Could not save product with position to category?

Instruction how to resolve issue in magento 2 when not possible to cahnge category in edit product mode and in category when open Product in category section.

 

download this extension:

 

https://yadi.sk/d/NK4ZUFlcMuf59w

 

install it and run full product url regeneration:

 

bin/magento ok:urlrewrites:regenerate

=====================

working ok way:

1. in ssh in mysql run ( keep in mind this is only for experts who know what they do -- will remove all your links and rewrite urls ):

use databse;

SET FOREIGN_KEY_CHECKS = 0; 

TRUNCATE TABLE url_rewrite; 

SET FOREIGN_KEY_CHECKS = 1;

exit;

2. us this https://github.com/olegkoval/magento2-regenerate_url_rewrites

run bin/magento ok:urlrewrites:regenerate --entity-type=category

run bin/magento ok:urlrewrites:regenerate

3. clean & flush cach & clean redis or other extra cache

4. use https://github.com/cadencelabs/urldedup

run bin/magento cadence:urldedup:categories

run bin/magento cadence:urldedup:products

read here https://www.cadence-labs.com/2017/11/magento-2-fix-duplicate-url-key-for-categories-and-products/

5. use https://github.com/elgentos/regenerate-catalog-urls

run 

 regenerate:product:url

 regenerate:category:url

 regenerate:category:path

clear & flush all types of caches

run cron

wait for some time while all backend proccesses will be completed approx. 30 minutes

DONE - all rewrite 

=====================

DELETE FROM url_rewrite WHERE entity_type='product' AND is_autogenerated='1';

The regenerated URLs still contain old url keys

This is most likely caused by faulty import data. Steps to fix it: - Backup your database - Remove old

category paths (url keys will be preserved) by running this query: DELETE FROM

catalog_category_entity_varchar WHERE attribute_id = ( SELECT attribute_id FROM

`eav_attribute` WHERE `attribute_code` = 'url_path' AND `entity_type_id` = '3' ) -

Remove old product paths by running this query: DELETE FROM catalog_product_entity_varchar

WHERE attribute_id = ( SELECT attribute_id FROM `eav_attribute` WHERE

`attribute_code` = 'url_path' AND `entity_type_id` = '4' )