Example #1
0
 private function _getCSVFileText()
 {
     $link = new Link();
     $schema = '';
     $schema .= $this->quoting . $this->_idealocsv->l('id', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('brand', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('title', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('Category', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('Short Description', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('description', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('image_link', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('link', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('price', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('ean', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('availability', 'idealo') . $this->quoting . $this->fieldseparator;
     foreach ($this->shipping as $ship) {
         if ($ship['active'] == '1') {
             foreach ($this->payment as $pay) {
                 if ($pay['active'] == '1') {
                     $schema .= $this->quoting . strtoupper($pay['db']) . '_' . $ship['country'] . $this->quoting . $this->fieldseparator;
                 }
             }
         }
     }
     foreach ($this->shipping as $ship) {
         if ($ship['active'] == '1') {
             $schema .= $this->quoting . $this->_idealocsv->l('shipping', 'idealo') . '_' . $ship['country'] . $this->quoting . $this->fieldseparator;
         }
     }
     $schema .= $this->quoting . $this->_idealocsv->l('shipping_weight', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('baseprice', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('EAN', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('condition', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . 'portocomment' . $this->quoting . $this->fieldseparator;
     if ($this->minOrderPrice != '') {
         $schema .= $this->quoting . $this->_idealocsv->l('Small order value surcharge', 'idealo') . $this->quoting . $this->fieldseparator;
     }
     $schema .= $this->quoting . 'Attributes' . $this->quoting . $this->fieldseparator;
     $schema .= "\n";
     setlocale(LC_ALL, 'de_DE');
     $date = date("d.m.y H:i:s");
     $schema .= $this->quoting . sprintf($this->_idealocsv->l('Last file created on %s o\'clock', 'idealo'), $date) . $this->quoting . $this->fieldseparator;
     $schema .= "\n";
     $schema .= sprintf($this->_idealocsv->l('idealo - CSV export-modul V %s for PrestaShop from %s', 'idealo'), IDEALO_MODULE_VERSION, IDEALO_MODULE_DATE);
     $schema .= "\n";
     $article = $this->getArticleNumbers();
     foreach ($article as $a) {
         $product = new Product($a['id_product'], false, $this->id_lang);
         $productlink = $product->getLink();
         if ($this->campaign == '1') {
             $productlink .= CAMPAIGN;
         }
         $cat = $product->getProductCategoriesFull($a['id_product'], $this->id_lang);
         $brand = $this->getBrand($product->id_manufacturer);
         $cat_text = $this->getCatText($cat);
         if ($this->checkFilter($cat_text, $brand, $a['id_product']) === true) {
             $images = $product->getCover($a['id_product']);
             $imagelink = $link->getImageLink($product->link_rewrite[1], $product->id . '-' . $images['id_image'], '');
             $price = number_format($product->getprice(), 2, '.', '');
             $attributeCombinations = $product->getAttributeCombinaisons($this->id_lang);
             if (!empty($attributeCombinations)) {
                 $attributeCombinations = $this->sortAttributeCombinations($attributeCombinations);
                 $taxRate = $this->getTaxRate($product->id_tax_rules_group);
                 $i = 1;
                 foreach ($attributeCombinations as $combination) {
                     if ($combination[0]['quantity'] > 0) {
                         $image = '';
                         $image_id = $this->getImegeLinkOfAtrribute($combination[0]['id_product_attribute']);
                         if ($image_id == 0) {
                             $image = $imagelink;
                         } else {
                             $image = new Image($image_id);
                             $image = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image->getExistingImgPath() . '.jpg';
                         }
                         $articleId = $a['id_product'] . '_' . $i;
                         $combinationString = $this->getCombinationString($combination);
                         $title = $product->name . ' ' . str_replace(';', ',', $combinationString);
                         $combinationPrice = $price + number_format($combination[0]['price'] * (1 + $taxRate / 100), 2, '.', '');
                         $weight = $product->weight + $combination[0]['weight'];
                         $combinationEan = $combination[0]['ean13'];
                         $schema .= $this->getProductLine($product, $articleId, $brand, $title, $cat_text, $image, $productlink, $combinationPrice, $weight, $combinationString, ${$combinationEan});
                     }
                     $i++;
                     if ($i >= 100) {
                         break;
                     }
                 }
             } else {
                 $schema .= $this->getProductLine($product, $a['id_product'], $brand, $product->name, $cat_text, $imagelink, $productlink, $price, $product->weight);
             }
         }
     }
     return $schema;
 }