Last active
August 29, 2015 14:07
-
-
Save larascasse/82511c440e82d4da4c7e to your computer and use it in GitHub Desktop.
Magento Duplicate category
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 catalog_category_product | |
SELECT {{NEWCATEGORY}} as category_id, tablea.product_id, 999 as position | |
FROM `catalog_category_product` tablea | |
LEFT OUTER JOIN `catalog_category_product` tableb | |
ON tablea.product_id = tableb.product_id | |
AND tableb.category_id = {{NEWCATEGORY}} | |
WHERE tablea.`category_id` = {{OLDCATEGORY}} AND tableb.position is NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
INSERT INTO catalog_category_product
SELECT 28 as category_id, tablea.product_id, 999 as position
FROM catalog_category_product tablea
LEFT OUTER JOIN catalog_category_product tableb
ON tablea.product_id = tableb.product_id
AND tableb.category_id = 28
WHERE tablea.category_id = 16 AND tableb.position is NULL