Skip to content

Instantly share code, notes, and snippets.

@JesusLeon
Created May 13, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JesusLeon/5a87e38195a48690606b961c094dfac2 to your computer and use it in GitHub Desktop.
Save JesusLeon/5a87e38195a48690606b961c094dfac2 to your computer and use it in GitHub Desktop.
$article_supplier = Shopware()->Db()->fetchAll("SELECT a.id article, s.name supplier FROM s_articles a, s_articles_vote av, s_articles_supplier s WHERE a.id = av.articleID AND s.id = a.supplierID GROUP BY (av.articleID)");
foreach ($article_supplier as $a_s) {
$sql = "UPDATE `s_articles_vote`
SET
`supplierName` = '" . $a_s['supplier'] . "'
WHERE
`voteID` = '" . $a_s['article'] . "'
";
Shopware()->Db()->query($sql);
}
UPDATE s_articles_vote av
INNER JOIN (
SELECT a.id article, s.name supplier FROM s_articles a, s_articles_vote av, s_articles_supplier s WHERE a.id = av.articleID AND s.id = a.supplierID GROUP BY (av.articleID)
) AS s
SET av.supplierName = s.supplier
WHERE av.`articleID` = s.article
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment