Jocafri Posted May 17, 2023 Share Posted May 17, 2023 Hola! No estoy muy puesto en SQL por eso necesito ayuda para realizar una consulta que pueda extraer de Prestashop 1.7 la siguiente información: id producto nombre categoría marca combinaciones (si es que tiene) ventas fecha creación fecha activación Gracias! Link to comment Share on other sites More sharing options...
JuanjoG Posted May 23, 2023 Share Posted May 23, 2023 (edited) Hola te dejo el código para ello, recuerda que deberás de cambiar el prefijo de las tablas. SELECT p.id_product AS 'ID Producto', pl.name AS 'Nombre', cl.name AS 'Categoría', m.name AS 'Marca', COUNT(DISTINCT o.id_order) AS 'Ventas', p.date_add AS 'Fecha Creación', p.date_upd AS 'Fecha Activación', GROUP_CONCAT(DISTINCT CONCAT(a.name, ': ', al.name) SEPARATOR ', ') AS 'Combinaciones' FROM ps_product p LEFT JOIN ps_product_lang pl ON p.id_product = pl.id_product LEFT JOIN ps_category_lang cl ON p.id_category_default = cl.id_category LEFT JOIN ps_product_shop ps ON p.id_product = ps.id_product LEFT JOIN ps_manufacturer m ON p.id_manufacturer = m.id_manufacturer LEFT JOIN ps_product_attribute pa ON p.id_product = pa.id_product LEFT JOIN ps_product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute LEFT JOIN ps_attribute_lang a ON pac.id_attribute = a.id_attribute LEFT JOIN ps_attribute_group_lang ag ON a.id_attribute_group = ag.id_attribute_group LEFT JOIN ps_attribute_lang al ON pac.id_attribute = al.id_attribute AND al.id_lang = pl.id_lang LEFT JOIN ps_order_detail od ON p.id_product = od.product_id LEFT JOIN ps_orders o ON od.id_order = o.id_order WHERE ps.active = 1 GROUP BY p.id_product ORDER BY p.date_add DESC; Edited May 23, 2023 by JuanjoG (see edit history) Link to comment Share on other sites More sharing options...
Jocafri Posted May 31, 2023 Author Share Posted May 31, 2023 Hola Juanjo, Gracias por la respuesta pero me da el siguiente error: Quote El atributo "id_attribute_group" no existe en la tabla "ps_attribute_lang". Link to comment Share on other sites More sharing options...
JuanjoG Posted May 31, 2023 Share Posted May 31, 2023 Revisa que el prefijo de la tabla sean igual y que existe en la base de datos está tabla Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now