-
-
Save lsauer/1210023 to your computer and use it in GitHub Desktop.
insert update url rewrite
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
#INSERT INTO `core_url_rewrite` (`store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`) | |
SELECT 1 AS `store_id`, | |
`sub`.`category_id`, | |
`sub`.`entity_id` AS `product_id`, | |
CONCAT('product', '/', `entity_id`, '/', `category_id`) AS `id_path`, | |
`value` AS `request_path`, | |
CONCAT('catalog/product/view/id/', `entity_id`, '/category/', `category_id`) AS `target_path`, | |
1 AS `is_system` | |
FROM | |
(SELECT | |
'/' AS `path`, | |
#`pv`.`value`, | |
CONCAT(REPLACE(`cpe`.`sku`, 'US ', 'used-'), '.html') as `value`, | |
`pv`.`entity_id`, | |
`cpe`.`sku`, | |
`ccp`.`category_id` | |
FROM `catalog_product_entity_varchar` AS `pv` | |
INNER JOIN `catalog_category_product` AS `ccp` | |
ON `ccp`.`product_id` = `pv`.`entity_id` AND ccp.category_id != 2 | |
INNER JOIN `catalog_product_entity` AS `cpe` | |
ON `cpe`.`entity_id` = `pv`.`entity_id` | |
LEFT JOIN `catalog_category_entity_varchar` AS `cv` | |
ON `cv`.`entity_id` = `ccp`.`category_id` AND `cv`.`attribute_id` = 49 | |
WHERE (`pv`.`attribute_id` = 87) | |
GROUP BY `path`,`cv`.`value`) | |
AS `sub` | |
#ON DUPLICATE KEY | |
#UPDATE `store_id` = VALUES(`store_id`), `category_id` = VALUES(`category_id`), `product_id` = VALUES(`product_id`), `id_path` = VALUES(`id_path`), `request_path` = VALUES(`request_path`), `target_path` = VALUES(`target_path`), `is_system` = VALUES(`is_system`) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment