Baba deCode Posted October 21, 2015 Share Posted October 21, 2015 (edited) Bonjour,Il est étonnant que personne ne donne un moyen d'exporter (et du coup d'importer) les déclinaisons de produits via le SQL manager.J'ai une grosse difficulté à terminer la réalisation de la requête pour la faire correspondre exactement au fichier csv d'exemple de prestashop. Le probleme se pose quand il y a plusieurs groupes d'attributs sur une même reference "id_product_attribute". A l'heure actuelle la requete extrait les combinaisons ligne par ligne distinctivement. Donc il faut que je regroupe a la main avec un tri par id_product_attribute, c'est assez relou. J'aimerai pouvoir avoir exactement une colonne Attribute (Name:Type:Position)* avec les différent attributs séparés par une virgule Value (Value:Position)* avec les différentes valeurs des attributs séparées par une virgule SELECT p.`id_product` AS ID, CONCAT (agl.`name`,':',ag.`group_type`,':',ag.`position`) AS Attribute, CONCAT (al.`name`,':',a.`position`) AS Value, pa.supplier_reference AS Suplier_Reference, pa.reference AS Reference, pa.ean13 AS EAN13, pa.upc AS UPC, pa.wholesale_price AS Wholesale_Price, pa.`price` AS Price_Impact, pa.`ecotax`, pa.`quantity` AS Quantity_Pa, sa.`quantity` AS Quantity_Stock_available, pa.`minimal_quantity` AS Minimal_Quantity, pa.`weight` AS Impact_On_Weight, pa.`default_on`, pa.`available_date` AS Combination_Available_Date, ag.`is_color_group`, a.`id_attribute`, a.`color` AS Attribute_Color, pa.`id_product_attribute` FROM `ps_product` p LEFT JOIN `ps_product_attribute` pa ON (p.id_product = pa.id_product) LEFT JOIN `ps_product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `ps_attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `ps_stock_available` sa ON pac.`id_product_attribute` = sa.`id_product_attribute` LEFT JOIN `ps_attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `ps_attribute_lang` al ON a.`id_attribute` = al.`id_attribute` LEFT JOIN `ps_attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE al.`id_lang` = 1 AND agl.`id_lang` = 1 ORDER BY p.`id_product` Si quelqu'un de doué passe par la, je pense que ca pourra en aider beaucoup.CDT Edited October 21, 2015 by Alexandre-KM (see edit history) Link to comment Share on other sites More sharing options...
hshaker Posted May 14, 2020 Share Posted May 14, 2020 (edited) Quote SELECT p.id_product AS 'ID produit', pa.reference AS 'Référence du produit', CONCAT (agl.name,':',ag.group_type,':',ag.position) AS 'Attribut (Nom:Type:Position)*', CONCAT (al.name,':',a.position) AS 'Valeur (Valeur:Position)*', pa.supplier_reference AS 'Référence fournisseur', p.reference AS 'Référence', pa.ean13 AS 'EAN_13', pa.upc AS 'UPC', pa.wholesale_price AS 'Prix d_achat', pa.price AS 'Impact sur le prix', pa.ecotax AS 'Eco-participation', pa.quantity AS 'Quantité', pa.minimal_quantity AS 'Quantité minimale', pa.low_stock_threshold AS 'Niveau de stock bas', pa.low_stock_alert AS 'Email quand la quantité est en dessous de ce niveau', pa.unit_price_impact AS 'Impact sur le poids', '' AS 'Valeurs par défaut (0 = Non, 1 = Oui)', pa.available_date AS 'Date de disponibilité de la déclinaison' FROM ps_product p LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product) LEFT JOIN ps_product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute LEFT JOIN ps_attribute a ON a.id_attribute = pac.id_attribute LEFT JOIN ps_stock_available sa ON pac.id_product_attribute = sa.id_product_attribute LEFT JOIN ps_attribute_group ag ON ag.id_attribute_group = a.id_attribute_group LEFT JOIN ps_attribute_lang al ON a.id_attribute = al.id_attribute LEFT JOIN ps_attribute_group_lang agl ON ag.id_attribute_group = agl.id_attribute_group WHERE al.id_lang = 1 AND agl.id_lang = 1 ORDER BY p.id_product à essayer 😉 Edited May 14, 2020 by hshaker (see edit history) 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