great snippet
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | SELECT p.id_product, pa.reference, pl. name , @id_image := ifnull(pai.id_image, pi.id_image) as id_image, ifnull(shop_domain.value, 'domain' ), '/img/p/' , if(CHAR_LENGTH(@id_image) >= 5, concat( SUBSTRING (@id_image from - 5 FOR 1), '/' ), '' ), if(CHAR_LENGTH(@id_image) >= 4, concat( SUBSTRING (@id_image from - 4 FOR 1), '/' ), '' ), if(CHAR_LENGTH(@id_image) >= 3, concat( SUBSTRING (@id_image from - 3 FOR 1), '/' ), '' ), if(CHAR_LENGTH(@id_image) >= 2, concat( SUBSTRING (@id_image from - 2 FOR 1), '/' ), '' ), if(CHAR_LENGTH(@id_image) >= 1, concat( SUBSTRING (@id_image from - 1 FOR 1), '/' ), '' ), @id_image, '.jpg' ) as image_url, GROUP_CONCAT( DISTINCT (pal. name ) SEPARATOR ', ' ) as combination, ROUND(p.price, 2) as price, p.active, pq.quantity FROM ps_product p LEFT JOIN ps_product_attribute pa ON (p.id_product = pa.id_product) LEFT JOIN ps_stock_available pq ON (p.id_product = pq.id_product AND pa.id_product_attribute = pq.id_product_attribute) LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN ps_attribute_lang pal ON (pac.id_attribute = pal.id_attribute) LEFT JOIN ps_product_attribute_image pai ON (pa.id_product_attribute = pai.id_product_attribute) LEFT JOIN ps_image pi ON p.id_product = pi.id_product LEFT JOIN ps_configuration shop_domain ON shop_domain. name = 'PS_SHOP_DOMAIN' WHERE pl.id_lang = ( SELECT id_lang FROM ps_lang ORDER BY id_lang ASC LIMIT 1 ) AND pal.id_lang = pl.id_lang GROUP BY pa.reference ORDER BY p.id_product , pac.id_attribute; |
Original discussion URL
https://www.prestashop.com/forums/topic/329498-export-all-products-including-combinations/page-2
https://www.prestashop.com/forums/topic/329498-export-all-products-including-combinations/page-2