Skip to content

Instantly share code, notes, and snippets.


Rahul Anand rahulanand77

View GitHub Profile
rahulanand77 / gist:f65089870d462b39a18653bc4be8912b
Last active Oct 12, 2016
update url_rewrite entity_id as per target_path product ID
View gist:f65089870d462b39a18653bc4be8912b
#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'
You can’t perform that action at this time.