Ejemplo n.º 1
0
 /**
  * Generates and returns the array of datafeed
  *
  * @param stdClass $queryParameters
  * @param array $fieldMap
  * @return stdClass
  */
 public function getFeed(stdClass $queryParameters, array $fieldMap)
 {
     set_time_limit(1800);
     header('Content-Encoding: UTF-8');
     header("Content-type: text/csv; charset=UTF-8");
     header('Content-Disposition: attachment; filename=oscommerceview.csv');
     mb_internal_encoding("UTF-8");
     $fh = fopen("php://output", 'w+');
     fputcsv($fh, array_keys($fieldMap), ';', '"');
     $specials = $this->config->getSpecials();
     $this->config->setLanguage($queryParameters->language);
     $this->config->setCurrencyParam($queryParameters->currency);
     $this->config->setStatus($queryParameters->condition);
     $this->config->initPreselectedFields();
     $sql = $this->config->getQuery($queryParameters->language);
     $result = tep_db_query($sql);
     while ($row = tep_db_fetch_array($result)) {
         if (isset($specials[$row['products_id']])) {
             $row = array_merge($row, $specials[$row['products_id']]);
         }
         if ($attributes = $this->config->getCombinationsOfAttributes($row)) {
             foreach ($attributes as $key => $attribute) {
                 $row['attribute'] = $attribute;
                 $this->config->getFeedRow($fieldMap, $row, $fh);
             }
         } else {
             $this->config->getFeedRow($fieldMap, $row, $fh);
         }
     }
     fclose($fh);
 }