Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antoineguilbert/0a28593346428347f8cd2ea140c7c7cc to your computer and use it in GitHub Desktop.
Save antoineguilbert/0a28593346428347f8cd2ea140c7c7cc to your computer and use it in GitHub Desktop.
Get easily with a SQL command products with categories on Prestashop
SELECT p.id_product, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.reference, pm.name, pl.description_short, pl.description, p.date_add
FROM ps_product p
LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product)
LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)
LEFT JOIN ps_category c ON (cp.id_category = c.id_category)
LEFT JOIN ps_manufacturer pm ON (p.id_manufacturer = pm.id_manufacturer)
WHERE pl.id_lang = 1
AND cl.id_lang = 1
AND p.id_shop_default = 1
AND c.id_shop_default = 1
GROUP BY p.id_product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment