Bonjour,

Je vous sollicite aujourd'hui car je m'arrache un peu les cheveux sur un problème surement très simple mais qui me bloc à cause de mon niveau médiocre en SQL.

Voila j'essai de modifier un plugin sous prestashop et j'ai une requête qui me renvoi qu'une ligne sur les deux.

Dans ma table (associates) il y a :

id | id_product_1 | id_product_2 | number | taxonomy

246251 | 273 | 754 | 8 | schema
246252 | 273 | 754 | 7 | schema


et voici la requête

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
SELECT  p.*, product_shop.*,
					stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
					MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity,
					pl.*, MAX(image_shop.`id_image`) id_image, il.`legend`,
					m.`name` as manufacturer_name, cl.`name` AS category_default,
                                        DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(int)$new.' DAY)) > 0 new
                    , a.number as number
                                FROM `'._DB_PREFIX_.'associates` a
                                LEFT JOIN `'._DB_PREFIX_.'product` p ON ( p.`id_product` = `id_product_2`)
                                '.Shop::addSqlAssociation('product', 'p').'
                                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)self::$id_lang.Shop::addSqlRestrictionOnLang('pl').')
                                LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
                                ON (p.`id_product` = pa.`id_product`)
                                '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
                                LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)self::$id_lang.Shop::addSqlRestrictionOnLang('cl').')
                                LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'.
                                Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
                                LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)self::$id_lang.')
                                LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (p.`id_manufacturer`= m.`id_manufacturer`)
                                '.Product::sqlStock('p', 0).'
                                WHERE 1
                                AND a.id_product_2 != 0
                                AND a.taxonomy = \''.pSQL($taxonomy).'\'
                                '.($id_product?'AND a.id_product_1 ='.(int)$id_product:'').'
                                '.($active ? ' AND product_shop.`active` = 1 AND product_shop.`visibility` != \'none\'' : '').'
                                GROUP BY product_shop.id_product
				ORDER BY number
				';

Pouvez-vous me dire ce qui fait que sur les deux lignes qu'il devrait me renvoyer il ne m'en renvoi qu'une seule ? Je pense que c'est à cause du GROUP BY mais si je le retire ça ne fonctionne plus...


Merci d'avance pour votre aide.