Skip to content

Instantly share code, notes, and snippets.

View rahulanand77's full-sized avatar

Rahul Anand rahulanand77

View GitHub Profile
@rahulanand77
rahulanand77 / gist:f65089870d462b39a18653bc4be8912b
Last active October 12, 2016 12:03
update url_rewrite entity_id as per target_path product ID
#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'