Skip to content

Instantly share code, notes, and snippets.

@selinerdominik
Last active December 20, 2015 19:28
Show Gist options
  • Save selinerdominik/6183236 to your computer and use it in GitHub Desktop.
Save selinerdominik/6183236 to your computer and use it in GitHub Desktop.
Get All Prestashop product_attribute combinations with their ean13 code and supplier_reference
SELECT ppl.name, group_concat(al.name SEPARATOR ',') as attributes, pa.ean13, pa.supplier_reference
FROM ps_product AS pp, ps_product_lang AS ppl, ps_attribute_lang AS al, ps_product_attribute AS pa, ps_product_attribute_combination AS pac
WHERE pp.id_product = ppl.id_product
AND pp.id_product = pa.id_product
AND pa.id_product_attribute = pac.id_product_attribute
AND pac.id_attribute = al.id_attribute
AND ppl.id_lang =4
AND al.id_lang =4
AND id_supplier =5
GROUP BY pa.id_product_attribute
ORDER BY ppl.name;
SELECT ma.name, ppl.name, group_concat( al.name
SEPARATOR ',' ) AS attributes, pa.ean13
FROM ps_product AS pp, ps_product_lang AS ppl, ps_attribute_lang AS al, ps_product_attribute AS pa, ps_product_attribute_combination AS pac, ps_manufacturer AS ma
WHERE pp.id_product = ppl.id_product
AND pp.id_manufacturer = ma.id_manufacturer
AND pp.id_product = pa.id_product
AND pa.id_product_attribute = pac.id_product_attribute
AND pac.id_attribute = al.id_attribute
AND ppl.id_lang =4
AND al.id_lang =4
AND id_supplier =5
GROUP BY pa.id_product_attribute
ORDER BY ma.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment