title: Exporting Products Catalog from Prestashop 1.7 to csv file to use on Facebook Shop
body: <p>that is working but i have on the product id´s not all in numeric order, for example, i have product id like (1,2,3,4,5,7,10,12,13,14, etc...)</p>
  <p>When the script generates de file it creates like, product id (1,2,3,4,5,6,7,8,9,10,11,12,13,14, etc..) and on the id´s that there is not product information it creates a blank id line.</p>
  <p>Can some help me to fix this ?</p>
  <p>Regard´s</p>
  <pre><code>&lt;?php
     // Connecting to database
     
     $con = mysqli_connect('127.0.0.1', 'root', '', 'prestahop');
     
     // check connection
     
     if(mysqli_connect_errno())
     {
         echo &quot;Failed to connect to Mysql : &quot; .mysqli_connect_errno();
             
     }
     
     
     $domain = &quot;127.0.0.1/prestashop&quot;;
     
      $names = array();
      $descriptions = array();
      $limit = array();
      $skus = array();
      $prices = array();
       
     
     $stmt = $con-&gt;prepare(&quot;SELECT id_product,name,description FROM ps_product_lang where id_lang = 1&quot;);
     
     $stmt-&gt;execute();
     $stmt-&gt;store_result();
     //$stmt-&gt;bind_result($active,$id,$name,$description);
     $stmt-&gt;bind_result($id,$name,$description);
     
     while($stmt-&gt;fetch())
     
     {
         
         //saving names and descriptions in associative array with id as key
         
         $names[$id] = $name;
         $descriptions[$id] = $description;
         
     }
     
     $stmt-&gt;close();
     
     $stmt = $con-&gt;prepare(&quot;SELECT id_product,reference,price FROM ps_product&quot;);
     $stmt-&gt;execute();
     $stmt-&gt;store_result();
     $stmt-&gt;bind_result($id,$reference,$price);
     
     while($stmt-&gt;fetch())
     
     {
         $limit[] = $id;
             
         //saving id, skus and price in associative array with id as key
         
         $ids[$id] = $id;
         $skus[$id] = $reference;
         $prices[$id] = $price;
     }
     
     $stmt-&gt;close();
     
     $fp = fopen(&quot;fbshop.csv&quot;,&quot;w&quot;);
     
     // setting column headers
     
     $fields = array(
     
                  'id',
                  'title',
                  'description',
                  'availability',
                  'condition',
                  'price',
                  'link',
                  'image_link',
                  'brand',
                  'additional_image_link',
                  'age_group'
     
                  );
       fputcsv($fp,$fields); 
       $count = 1;
     
       while($count &lt; count($limit))
       {
         $lineData = array(
             
             $ids[$count],
             $names[$count],
             //$descriptions[$count],
             strip_tags($descriptions[$count]),
             'in stock',
             'New',
             number_format((float)$prices[$count],2,'.',''),
             $domain . 'index.php?id_product=' . $ids[$count] . '&amp;controller=product',
             $domain . $ids[$count] . '-large_default/' . str_replace(&quot; &quot;,&quot; &quot;,strtolower($names[$count])) . '.jpg',
             'BrandName',
             $domain . $ids[$count] . '-large_default/' . str_replace(&quot; &quot;,&quot;-&quot;,strtolower($names[$count])) . '.jpg',
             'adult'
          );  
           
           fputcsv($fp,$lineData);
           $count++;
           
           
       }
     
     fclose($fp);
     
     ?&gt;
  </code></pre>