Jump to content

Edit History

JuanjoG

JuanjoG

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;

 

JuanjoG

JuanjoG

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'
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_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;

 

×
×
  • Create New...