title: Export stock of products with attributes in Prestashop
body: <p>In my shop the Product A has different attributes, let them be: <br>
  White (12pcs left), Black (10 left) and Red (6 left) <br>
  I have managed to export into csv all products with their categories and quantities and attributes, but I would like the table to look as follows: <br>
  Product A / White / 12 <br>
  Product A / Black / 10 <br>
  Product A / Red / 6 <br>
  Product B / Size S / 5 <br>
  Product B / Size M / 6 <br></p>
  
  <p>So all the quantities available for each combination of the product.
  My query now is as follows:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>SELECT 
      p.id_product,
      p.id_category_default,
      GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ";") as categories,
      pa.reference,
      pl.name, 
      GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR "; ") as combination, 
      p.price, 
      pq.quantity
  FROM 7_ps_product p 
  LEFT JOIN 7_ps_product_attribute pa ON (p.id_product = pa.id_product) 
  LEFT JOIN 7_ps_stock_available pq ON (p.id_product = pq.id_product AND pa.id_product_attribute = pq.id_product_attribute) 
  LEFT JOIN 7_ps_product_lang pl ON (p.id_product = pl.id_product) 
  LEFT JOIN 7_ps_product_attribute_combination pac ON (pa.id_product_attribute = pac.id_product_attribute)
  LEFT JOIN 7_ps_attribute_lang pal ON (pac.id_attribute = pal.id_attribute)
  LEFT JOIN 7_ps_category_product cp ON (p.id_product = cp.id_product)
  LEFT JOIN 7_ps_category_lang cl ON (cp.id_category = cl.id_category)
  LEFT JOIN 7_ps_category c ON (cp.id_category = c.id_category)
  WHERE pl.id_lang = 1 
  AND pal.id_lang = 1 
  GROUP BY pa.reference
  ORDER BY p.id_product, pac.id_attribute</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks for great contributions to help out people like me!!</p>