Last active
January 14, 2021 18:07
-
-
Save Crease29/93216af9f0c34fe56c2595f37350bb85 to your computer and use it in GitHub Desktop.
Shopware 6: Set smallest active product.main_variant_id (ordered by variant product_number)
This file contains hidden or 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
UPDATE product AS mainProduct | |
SET main_variant_id = ( | |
SELECT p.id | |
FROM product AS p | |
INNER JOIN product_option AS po | |
ON p.id = po.product_id | |
INNER JOIN property_group_option AS pgo | |
ON po.property_group_option_id = pgo.id | |
WHERE p.parent_id = mainProduct.id | |
AND (p.active IS NULL OR p.active = 1) | |
GROUP BY p.product_number | |
ORDER BY p.product_number | |
LIMIT 1 | |
) | |
WHERE mainProduct.parentId IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment