Last active
December 19, 2024 12:35
-
-
Save steffen-wirth/86fcfc862dcff6c69a12b801c7808916 to your computer and use it in GitHub Desktop.
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
## https://forum.shopware.com/t/bild-als-cover-setzen-bei-mehrfachaenderung/96122/14 | |
## set cover image | |
UPDATE | |
product p | |
LEFT JOIN product_media pm ON (p.id = pm.product_id AND p.version_id = pm.product_version_id AND pm.position = ( | |
SELECT | |
min(position) | |
FROM | |
product_media | |
WHERE | |
product_id = p.id AND product_version_id = p.version_id)) | |
LEFT JOIN product AS pp ON (p.parent_id = pp.id AND p.parent_version_id = pp.version_id) | |
LEFT JOIN product_media ppm ON (pp.id = ppm.product_id AND pp.version_id = ppm.product_version_id AND ppm.position = ( | |
SELECT | |
min(position) | |
FROM | |
product_media | |
WHERE | |
product_id = pp.id AND product_version_id = pp.version_id)) | |
SET p.product_media_id = IF(pm.id IS NOT NULL, pm.id, ppm.id), p.cover = IF(pm.id IS NOT NULL, pm.id, ppm.id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment