Last active
October 12, 2016 12:03
-
-
Save rahulanand77/f65089870d462b39a18653bc4be8912b to your computer and use it in GitHub Desktop.
update url_rewrite entity_id as per target_path product ID
This file contains 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
#Run the below sql command to find products in url_rewrite on MariaDB which does not have same entity_id as target_path | |
SELECT regexp_substr(`target_path`, '([0-9]+)'), `target_path` FROM `url_rewrite` WHERE `target_path` REGEXP | |
'/id/([0-9]+)' AND `entity_type` = 'product'; | |
#Below update command will update differ entity_id to same as target_path product_id on MariaDB | |
UPDATE `url_rewrite` AS `master` | |
JOIN `url_rewrite` AS `child` ON `master`.`entity_id` | |
NOT LIKE concat("%/id/", `master`.`entity_id`,"%") AND `master`.`entity_type`='product' | |
SET `master`.`entity_id` = regexp_substr(`master`.`target_path`, '([0-9]+)'); | |
Note* above queries will work on MariaDB only. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment