protected function generateProductsData()
    {
        $delimiter = ';';
        $titles = array();
        $id_lang = $this->use_lang;
        $new_path = new Sampledatainstall();
        $f = fopen($new_path->sendPath() . 'output/products.vsc', 'w');
        foreach ($this->product_fields as $field => $array) {
            $titles[] = $array['label'];
        }
        fputcsv($f, $titles, $delimiter, '"');
        $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', false, true);
        foreach ($products as $product) {
            $line = array();
            $p = new Product($product['id_product'], true, $id_lang, 1);
            foreach ($this->product_fields as $field => $array) {
                $line[$field] = property_exists('Product', $field) && !is_array($p->{$field}) && !Tools::isEmpty($p->{$field}) ? $p->{$field} : '';
            }
            $cats = $p->getProductCategoriesFull($p->id, 1);
            $cat_array = array();
            foreach ($cats as $cat) {
                $cat_array[] = $cat['id_category'];
            }
            $line['categories'] = implode(',', $cat_array);
            $line['price_tex'] = $p->getPrice(false);
            $line['price_tin'] = $p->getPrice(true);
            $line['upc'] = $p->upc ? $p->upc : '';
            $line['features'] = '';
            $features = $p->getFrontFeatures($id_lang);
            $position = 1;
            $devider = '';
            foreach ($features as $feature) {
                $sql = 'SELECT `id_feature`
						FROM ' . _DB_PREFIX_ . 'feature_lang
						WHERE `name` = "' . pSql($feature['name']) . '"';
                $sql1 = 'SELECT `id_feature_value`
						FROM ' . _DB_PREFIX_ . 'feature_value_lang
						WHERE `value` = "' . pSql($feature['value']) . '"';
                $id_feature = Db::getInstance()->getValue($sql);
                $id_feature_value = Db::getInstance()->getValue($sql1);
                $line['features'] .= $devider . $id_feature . ':' . $id_feature_value . ':' . $position;
                $devider = ',';
                $position++;
            }
            $specificPrice = SpecificPrice::getSpecificPrice($p->id, 1, 0, 0, 0, 0);
            $line['reduction_price'] = '';
            $line['reduction_percent'] = '';
            $line['reduction_from'] = '';
            $line['reduction_to'] = '';
            if ($specificPrice) {
                if ($specificPrice['reduction_type'] == 'amount') {
                    $line['reduction_price'] = $specificPrice['reduction'];
                } elseif ($specificPrice['reduction_type'] == 'percent') {
                    $line['reduction_percent'] = $specificPrice['reduction'];
                }
                if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                    $line['reduction_from'] = $specificPrice['from'];
                    $line['reduction_to'] = $specificPrice['to'];
                }
            }
            $tags = $p->getTags($id_lang);
            $line['tags'] = $tags;
            $link = new Link();
            $imagelinks = array();
            $images = $p->getImages($id_lang);
            foreach ($images as $image) {
                $imagelink = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                $this->copyConverFileName($imagelink);
                $imagelinks[] = $imagelink;
            }
            $line['image'] = implode(',', $imagelinks);
            $line['delete_existing_images'] = 0;
            $line['shop'] = 1;
            $warehouses = Warehouse::getWarehousesByProductId($p->id);
            $line['warehouse'] = '';
            if (!empty($warehouses)) {
                $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
            }
            $values = array();
            $accesories = $p->getAccessories($id_lang);
            if (isset($accesories) && $accesories && count($accesories)) {
                foreach ($accesories as $accesorie) {
                    $values[] = $accesorie['id_product'];
                }
            }
            $line['accessories'] = $values ? implode(',', $values) : '';
            $values = array();
            $carriers = $p->getCarriers();
            if (isset($carriers) && $carriers && count($carriers)) {
                foreach ($carriers as $carrier) {
                    $values[] = $carrier['id_carrier'];
                }
            }
            $line['carriers'] = $values ? implode(',', $values) : '';
            $values = array();
            $customization_fields_ids = $p->getCustomizationFieldIds();
            if (class_exists('CustomizationField') && isset($customization_fields_ids) && $customization_fields_ids && count($customization_fields_ids)) {
                foreach ($customization_fields_ids as $customization_field_id) {
                    $cf = new CustomizationField($customization_field_id['id_customization_field'], $this->use_lang);
                    $values[] = $cf->id . ':' . $cf->type . ':' . $cf->required . ':' . $cf->name;
                }
            }
            $line['customization_fields_ids'] = $values ? implode(',', $values) : '';
            $values = array();
            $attachments = $p->getAttachments($this->use_lang);
            if (isset($attachments) && $attachments && count($attachments)) {
                foreach ($attachments as $attachment) {
                    $values[] = $attachment['id_attachment'];
                }
            }
            $line['attachments'] = $values ? implode(',', $values) : '';
            if (!property_exists('Product', 'base_price')) {
                // for versions < 1.6.0.13
                $line['base_price'] = !is_array($p->base_price) && !Tools::isEmpty($p->base_price) ? $p->base_price : '';
            }
            if (!$line[$field]) {
                $line[$field] = '';
            }
            fputcsv($f, $line, $delimiter, '"');
        }
        fclose($f);
    }
Example #2
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         // Product pictures management
         require_once 'images.inc.php';
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } else {
             if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
             }
         }
         $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
         $pictures = array();
         foreach ($files as $file) {
             $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
         }
         $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
         $text_fields = array();
         foreach ($texts as $text_field) {
             $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons'), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK')));
     }
     $this->context->smarty->assign('errors', $this->errors);
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
Example #3
0
 /**
  * @param Product $product to get the product properties
  * @param array $combination to get particular properties from a declination
  * @param int $lang id lang to take all text in good language
  * @param Link $link to set the link of the product and its images.
  * @param Carrier $carrier not used now, but usable for next version, needed for calculate the shipping cost,
  * 		  But for now it's not sure enough.
  * @return array with good value for the XML.
  */
 private function preparedValues(Product $product, $combination, $lang, Link $link, Carrier $carrier)
 {
     $arr_return = array();
     $str_features = array();
     $model = array();
     $version = str_replace('.', '', _PS_VERSION_);
     // To build description and model tags.
     if (isset($combination['attributes'])) {
         foreach ($combination['attributes'] as $attribut) {
             $str_features[] = $attribut['group_name'] . ' : ' . $attribut['name'];
             $model[] = $attribut['name'];
         }
     }
     if (isset($combination['weight']) && (int) $combination['weight'] !== 0) {
         $str_features[] = 'weight : ' . $combination['weight'];
     } elseif ($product->weight !== 0) {
         $str_features[] = 'weight : ' . $product->weight;
     }
     $features = $product->getFrontFeatures($lang);
     foreach ($features as $feature) {
         $str_features[] = $feature['name'] . ' : ' . $feature['value'];
     }
     // Category tag
     $category = new Category((int) $product->id_category_default, $lang);
     $category_path = (isset($category->id) and $category->id) ? Tools::getFullPath((int) $category->id, $product->name[$lang]) : Tools::getFullPath((int) $product->id_category_default, $product->name[$lang]);
     $category_path = Configuration::get('PS_NAVIGATION_PIPE') != false && Configuration::get('PS_NAVIGATION_PIPE') !== '>' ? str_replace(Configuration::get('PS_NAVIGATION_PIPE'), '>', $category_path) : $category_path;
     // image tag
     $id_image = isset($combination['id_image']) ? $combination['id_image'] : 0;
     if ($id_image === 0 || $id_image < 0) {
         $image = $product->getCover((int) $product->id);
         $id_image = $image['id_image'];
     }
     $quantity = Product::getQuantity($product->id, isset($combination['id_combination']) ? $combination['id_combination'] : NULL);
     $condition = '';
     if (strlen((string) $version) < 2) {
         $version = (string) $version . '0';
     }
     if ((int) substr($version, 0, 2) >= 14) {
         $condition = $product->condition === 'new' ? 0 : 1;
     }
     $price = $product->getPrice(true, isset($combination['id_combination']) ? $combination['id_combination'] : NULL, 2);
     $upc_ean = strlen((string) $product->ean13) == 13 ? $product->ean13 : '';
     $arr_return['product_url'] = $link->getProductLink((int) $product->id, $product->link_rewrite[$lang], $product->ean13, $lang);
     $arr_return['designation'] = Tools::htmlentitiesUTF8($product->name[$lang] . ' ' . Manufacturer::getNameById($product->id_manufacturer) . ' ' . implode(' ', $model));
     $arr_return['price'] = $price;
     $arr_return['category'] = Tools::htmlentitiesUTF8(strip_tags($category_path));
     if (substr(_PS_VERSION_, 0, 3) == '1.3') {
         if (!Configuration::get('PS_SHOP_DOMAIN')) {
             Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
         }
         $prefix = 'http://' . Configuration::get('PS_SHOP_DOMAIN') . '/';
         $arr_return['image_url'] = $prefix . $link->getImageLink('', $product->id . '-' . $id_image, 'large');
     } else {
         $arr_return['image_url'] = $link->getImageLink($product->link_rewrite[$lang], $product->id . '-' . $id_image, 'large');
     }
     // Must description added since Twenga-module v1.1
     $arr_return['description'] = is_array($product->description) ? strip_tags($product->description[$lang]) : strip_tags($product->description);
     $arr_return['description'] = trim($arr_return['description'] . ' ' . strip_tags(implode(', ', $str_features)));
     $arr_return['description'] = Tools::htmlentitiesUTF8($arr_return['description']);
     $arr_return['brand'] = Manufacturer::getNameById($product->id_manufacturer);
     $arr_return['merchant_id'] = $product->id;
     $arr_return['manufacturer_id'] = $product->id_manufacturer;
     $arr_return['shipping_cost'] = 'NC';
     $arr_return['in_stock'] = $quantity > 0 ? 'Y' : 'N';
     $arr_return['stock_detail'] = $quantity;
     $arr_return['condition'] = $condition;
     $arr_return['upc_ean'] = $upc_ean;
     $arr_return['eco_tax'] = $product->ecotax;
     // for prestashop 1.4 and previous version these fields are not managed.
     // So default values are set.
     $arr_return['product_type'] = '1';
     $arr_return['isbn'] = '';
     return $arr_return;
 }
 /**
  * Convert the entities data into an xml object and return the xml object as a string
  *
  * @param array $aEntity Entity data
  */
 public function formatEntityToXML($aEntity)
 {
     $sReturn = '';
     $dom = new DOMDocument('1.0', 'utf-8');
     $bUseRoutes = (bool) Configuration::get('PS_REWRITING_SETTINGS');
     $oDispatcher = Dispatcher::getInstance();
     // Force the dispatcher to use custom routes because the use of custom routes is disabled in the BO Context
     foreach ($oDispatcher->default_routes as $route_id => $route_data) {
         if ($custom_route = Configuration::get('PS_ROUTE_' . $route_id)) {
             foreach (Language::getLanguages() as $lang) {
                 $oDispatcher->addRoute($route_id, $custom_route, $route_data['controller'], $lang['id_lang'], $route_data['keywords'], isset($route_data['params']) ? $route_data['params'] : array());
             }
         }
     }
     $oPrediggoConfig = $this->aPrediggoConfigs[(int) $aEntity['id_shop']];
     $link = $oPrediggoConfig->getContext()->link;
     $oProduct = new Product((int) $aEntity['id_product'], true, null, (int) $aEntity['id_shop'], $oPrediggoConfig->getContext());
     if ((int) StockAvailable::getQuantityAvailableByProduct((int) $aEntity['id_product'], 0, (int) $aEntity['id_shop']) < (int) $oPrediggoConfig->export_product_min_quantity) {
         $this->nbEntitiesTreated--;
         $this->nbEntities--;
         return ' ';
     }
     $ps_tax = (int) Configuration::get('PS_TAX');
     foreach ($this->aLanguages as $aLanguage) {
         $id_lang = (int) $aLanguage['id_lang'];
         // Set the root of the XML
         $root = $dom->createElement($this->sEntity);
         $dom->appendChild($root);
         $root->setAttribute('timestamp', (int) strtotime($oProduct->date_add));
         $id = $dom->createElement('id', (int) $oProduct->id);
         $root->appendChild($id);
         $profile = $dom->createElement('profile', (int) $aEntity['id_shop']);
         $root->appendChild($profile);
         $name = $dom->createElement('name');
         $name->appendChild($dom->createCDATASection($oProduct->name[$id_lang]));
         $root->appendChild($name);
         $oCategory = new Category((int) $oProduct->id_category_default);
         $aCategories = $oCategory->getParentsCategories($id_lang);
         if (is_array($aCategories) && count($aCategories) > 0) {
             foreach ($aCategories as $aCategory) {
                 $oCategoryTmp = new Category((int) $aCategory['id_category'], $id_lang);
                 if (!empty($oCategoryTmp->name)) {
                     $genre = $dom->createElement('genre');
                     $genre->appendChild($dom->createCDATASection($oCategoryTmp->name));
                     $root->appendChild($genre);
                 }
                 unset($oCategoryTmp);
             }
         }
         unset($aCategories);
         unset($oCategory);
         if (!empty($oProduct->ean13)) {
             $ean = $dom->createElement('ean');
             $ean->appendChild($dom->createCDATASection($oProduct->ean13));
             $root->appendChild($ean);
         }
         $price = $dom->createElement('price', number_format($oProduct->getPrice($ps_tax), 2, '.', ''));
         $root->appendChild($price);
         if (isset($oProduct->tags[$id_lang]) && ($aTags = $oProduct->tags[$id_lang])) {
             $tag = $dom->createElement('tag');
             $tag->appendChild($dom->createCDATASection(join(',', $aTags)));
             $root->appendChild($tag);
         }
         $sDesc = trim(strip_tags($oProduct->description[$id_lang]));
         if ($oPrediggoConfig->export_product_description && !empty($sDesc)) {
             $description = $dom->createElement('description');
             $description->appendChild($dom->createCDATASection($sDesc));
             $root->appendChild($description);
         }
         if (!empty($oProduct->id_manufacturer)) {
             $supplierid = $dom->createElement('supplierid', (int) $oProduct->id_manufacturer);
             $root->appendChild($supplierid);
         }
         $recommendable = $dom->createElement('recommendable', in_array((int) $oProduct->id, explode(',', $oPrediggoConfig->products_ids_not_recommendable)) ? 'false' : 'true');
         $root->appendChild($recommendable);
         $searchable = $dom->createElement('searchable', in_array((int) $oProduct->id, explode(',', $oPrediggoConfig->products_ids_not_searchable)) ? 'false' : 'true');
         $root->appendChild($searchable);
         // Set product URL
         $attribute = $dom->createElement('attribute');
         $root->appendChild($attribute);
         $attName = $dom->createElement('attName', 'producturl');
         $attribute->appendChild($attName);
         $attValue = $dom->createElement('attValue');
         $attValue->appendChild($dom->createCDATASection($link->getProductLink((int) $oProduct->id, $oProduct->link_rewrite[$id_lang], Category::getLinkRewrite((int) $oProduct->id_category_default, $id_lang), NULL, $id_lang, (int) $aEntity['id_shop'], 0, $bUseRoutes)));
         $attribute->appendChild($attValue);
         // Set product picture
         if ($oPrediggoConfig->export_product_image) {
             $attribute = $dom->createElement('attribute');
             $root->appendChild($attribute);
             $attName = $dom->createElement('attName', 'imageurl');
             $attribute->appendChild($attName);
             $aCover = $oProduct->getCover((int) $oProduct->id);
             $attValue = $dom->createElement('attValue');
             $attValue->appendChild($dom->createCDATASection($link->getImageLink($oProduct->link_rewrite[$id_lang], (int) $aCover['id_image'], 'large')));
             $attribute->appendChild($attValue);
         }
         // Set combinations
         $aProductCombinations = Product::getAttributesInformationsByProduct((int) $oProduct->id);
         if (sizeof($aProductCombinations)) {
             foreach ($aProductCombinations as $aProductCombination) {
                 if (!empty($oPrediggoConfig->attributes_groups_ids) && in_array((int) $aProductCombination['id_attribute_group'], explode(',', $oPrediggoConfig->attributes_groups_ids))) {
                     $attribute = $dom->createElement('attribute');
                     $root->appendChild($attribute);
                     $attName = $dom->createElement('attName');
                     $attName->appendChild($dom->createCDATASection($aProductCombination['group']));
                     $attribute->appendChild($attName);
                     $attValue = $dom->createElement('attValue');
                     $attValue->appendChild($dom->createCDATASection($aProductCombination['attribute']));
                     $attribute->appendChild($attValue);
                 }
             }
         }
         unset($aProductCombinations);
         // Set features
         $aProductFeatures = $oProduct->getFrontFeatures($id_lang);
         if (sizeof($aProductFeatures)) {
             foreach ($aProductFeatures as $aProductFeature) {
                 if (!empty($oPrediggoConfig->features_ids) && in_array((int) $aProductFeature['id_feature'], explode(',', $oPrediggoConfig->features_ids))) {
                     $attribute = $dom->createElement('attribute');
                     $root->appendChild($attribute);
                     $attName = $dom->createElement('attName');
                     $attName->appendChild($dom->createCDATASection($aProductFeature['name']));
                     $attribute->appendChild($attName);
                     $attValue = $dom->createElement('attValue');
                     $attValue->appendChild($dom->createCDATASection($aProductFeature['value']));
                     $attribute->appendChild($attValue);
                 }
             }
         }
         unset($aProductFeatures);
         $aAccessories = Product::getAccessoriesLight($id_lang, (int) $oProduct->id);
         if (sizeof($aAccessories)) {
             foreach ($aAccessories as $aAccessory) {
                 $attribute = $dom->createElement('attribute');
                 $root->appendChild($attribute);
                 $attName = $dom->createElement('attName');
                 $attName->appendChild($dom->createCDATASection('accessory'));
                 $attribute->appendChild($attName);
                 $attValue = $dom->createElement('attValue');
                 $attValue->appendChild($dom->createCDATASection((int) $aAccessory['id_product']));
                 $attribute->appendChild($attValue);
             }
         }
         unset($aAccessories);
         $sReturn .= $dom->saveXML($root);
     }
     unset($dom);
     unset($oProduct);
     return $sReturn;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
             $this->product->quantity = 0;
         }
         $this->product->description = $this->transformDescriptionWithImg($this->product->description);
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
             $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
         }
         $pictures = array();
         $text_fields = array();
         if ($this->product->customizable) {
             $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
             foreach ($files as $file) {
                 $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
             }
             $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
             foreach ($texts as $text_field) {
                 $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
             }
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         $this->product->customization_required = false;
         $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
         if (is_array($customization_fields)) {
             foreach ($customization_fields as $customization_field) {
                 if ($this->product->customization_required = $customization_field['required']) {
                     break;
                 }
             }
         }
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $accessories = $this->product->getAccessories($this->context->language->id);
         if ($this->product->cache_is_pack || count($accessories)) {
             $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
         }
         if ($this->product->customizable) {
             $customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
         }
         // by webkul
         $htl_features = array();
         $obj_hotel_room_type = new HotelRoomType();
         $room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
         $hotel_id = $room_info_by_product_id['id_hotel'];
         if (isset($hotel_id) && $hotel_id) {
             $obj_hotel_branch = new HotelBranchInformation();
             $hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id);
             $hotel_policies = $hotel_info_by_id['policies'];
             $hotel_name = $hotel_info_by_id['hotel_name'];
             $country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']);
             $state = State::getNameById($hotel_info_by_id['state_id']);
             $hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country;
             $obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
             if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
                 foreach ($obj_hotel_feaures_ids as $key => $value) {
                     $obj_htl_ftr = new HotelFeatures();
                     $htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
                     $htl_features[] = $htl_info['name'];
                 }
             }
         }
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         if (!($date_from = Tools::getValue('date_from'))) {
             $date_from = date('Y-m-d');
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         if (!($date_to = Tools::getValue('date_to'))) {
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         $obj_booking_detail = new HotelBookingDetail();
         $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
         $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
         if (!$priceDisplay || $priceDisplay == 2) {
             $price_tax = true;
         } elseif ($priceDisplay == 1) {
             $price_tax = false;
         }
         $price_tax_incl = Product::getPriceStatic($this->product->id, $price_tax);
         $total_price = $price_tax_incl * $num_days;
         $obj_booking_dtl = new HotelBookingDetail();
         $hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1);
         $obj_htl_cart_booking_data = new HotelCartBookingData();
         $num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to);
         if ($hotel_room_data) {
             $total_available_rooms = $hotel_room_data['stats']['num_avail'] - $num_cart_rooms;
         }
         //end
         $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE');
         $hotel_branch_obj = new HotelBranchInformation();
         $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo();
         $search_data['date_from'] = $date_from;
         $search_data['date_to'] = $date_to;
         $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById($hotel_id);
         if (Tools::getValue('error')) {
             $this->context->smarty->assign('error', Tools::getValue('error'));
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'ratting_img_path' => _MODULE_DIR_ . 'hotelreservationsystem/views/img/Slices/icons-sprite.png', 'num_reviews' => ProductComment::getCommentNumber($this->product->id), 'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'], 'total_available_rooms' => $total_available_rooms, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable, 'total_price' => $total_price, 'product_controller_url' => $this->context->link->getPageLink('product'), 'num_days' => $num_days, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_location' => $hotel_location, 'hotel_name' => $hotel_name, 'hotel_policies' => $hotel_policies, 'hotel_features' => $htl_features, 'ftr_img_src' => _PS_IMG_ . 'rf/', 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'), 'search_data' => $search_data));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
Example #6
0
 public static function prepareTitle($data)
 {
     $product = new Product($data['real_id_product'], false, $data['id_lang']);
     $features = Feature::getFeatures($data['id_lang']);
     $features_product = $product->getFrontFeatures($data['id_lang']);
     $tags = array('{TITLE}', '{BRAND}', '{REFERENCE}', '{EAN}');
     $values = array($data['name'], $data['manufacturer_name'], $data['reference'], $data['ean13']);
     foreach ($features as $feature) {
         $tags[] = trim(str_replace(' ', '_', Tools::strtoupper('{FEATURE_' . $feature['name'] . '}')));
         $hasFeature = array_map(array('EbayRequest', 'getValueOfFeature'), $features_product, $feature);
         if (isset($hasFeature[0]) && $hasFeature[0]) {
             $values[] = $hasFeature[0];
         } else {
             $values[] = '';
         }
     }
     return EbaySynchronizer::fillTemplateTitle($tags, $values, $data['titleTemplate']);
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitExport')) {
         $delimiter = Tools::getValue('export_delimiter');
         $id_lang = Tools::getValue('export_language');
         $id_shop = (int) $this->context->shop->id;
         set_time_limit(0);
         $fileName = 'products_' . date("Y_m_d_H_i_s") . '.csv';
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header('Content-Description: File Transfer');
         header("Content-type: text/csv");
         header("Content-Disposition: attachment; filename={$fileName}");
         header("Expires: 0");
         header("Pragma: public");
         $f = fopen('php://output', 'w');
         foreach ($this->available_fields as $field => $array) {
             $titles[] = $array['label'];
         }
         fputcsv($f, $titles, $delimiter, '"');
         $export_active = Tools::getValue('export_active') == 0 ? false : true;
         $export_category = Tools::getValue('export_category') == 99999 ? false : Tools::getValue('export_category');
         $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', $export_category, $export_active);
         foreach ($products as $product) {
             $line = array();
             $p = new Product($product['id_product'], true, $id_lang, $id_shop);
             $p->loadStockData();
             foreach ($this->available_fields as $field => $array) {
                 if (isset($p->{$field}) && !is_array($p->{$field})) {
                     $line[$field] = $p->{$field} ? $p->{$field} : ' ';
                 } else {
                     switch ($field) {
                         case 'categories':
                             $cats = $p->getProductCategoriesFull($p->id, $id_lang);
                             $cat_array = array();
                             foreach ($cats as $cat) {
                                 $cat_array[] = $cat['name'];
                             }
                             $line['categories'] = implode(",", $cat_array);
                             break;
                         case 'price_tex':
                             $line['price_tex'] = $p->getPrice(false);
                             $line['price_tin'] = $p->getPrice(true);
                             break;
                         case 'upc':
                             $line['upc'] = $p->upc ? $p->upc : ' ';
                             break;
                         case 'features':
                             $line['features'] = '';
                             $features = $p->getFrontFeatures($id_lang);
                             $position = 1;
                             foreach ($features as $feature) {
                                 $line['features'] .= $feature['name'] . ':' . $feature['value'] . ':' . $position;
                                 $position++;
                             }
                             break;
                         case 'reduction_price':
                             $specificPrice = SpecificPrice::getSpecificPrice($p->id, $id_shop, 0, 0, 0, 0);
                             $line['reduction_price'] = '';
                             $line['reduction_percent'] = '';
                             $line['reduction_from'] = '';
                             $line['reduction_to'] = '';
                             if ($specificPrice['reduction_type'] == "amount") {
                                 $line['reduction_price'] = $specificPrice['reduction'];
                             } elseif ($specificPrice['reduction_type'] == "percent") {
                                 $line['reduction_percent'] = $specificPrice['reduction'];
                             }
                             if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                                 $line['reduction_from'] = date_format(date_create($specificPrice['from']), "Y-m-d");
                                 $line['reduction_to'] = date_format(date_create($specificPrice['to']), "Y-m-d");
                             }
                             break;
                         case 'tags':
                             $tags = $p->getTags($id_lang);
                             $line['tags'] = $tags;
                             break;
                         case 'image':
                             $link = new Link();
                             $imagelinks = array();
                             $images = $p->getImages($id_lang);
                             foreach ($images as $image) {
                                 $imagelinks[] = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                             }
                             $line['image'] = implode(",", $imagelinks);
                             break;
                         case 'delete_existing_images':
                             $line['delete_existing_images'] = 0;
                             break;
                         case 'shop':
                             $line['shop'] = $id_shop;
                             break;
                         case 'warehouse':
                             $warehouses = Warehouse::getWarehousesByProductId($p->id);
                             $line['warehouse'] = '';
                             if (!empty($warehouses)) {
                                 $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
                             }
                             break;
                         case 'date_added':
                             $date = new DateTime($p->date_add);
                             $line['date_add'] = $date->format("Y-m-d");
                             break;
                     }
                 }
             }
             if (!$line[$field]) {
                 $line[$field] = '';
             }
             fputcsv($f, $line, $delimiter, '"');
         }
         fclose($f);
         die;
     }
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
             $this->product->quantity = 0;
         }
         $this->product->description = $this->transformDescriptionWithImg($this->product->description);
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
             $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
         }
         $pictures = array();
         $text_fields = array();
         if ($this->product->customizable) {
             $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
             foreach ($files as $file) {
                 $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
             }
             $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
             foreach ($texts as $text_field) {
                 $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
             }
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         $this->product->customization_required = false;
         $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
         if (is_array($customization_fields)) {
             foreach ($customization_fields as $customization_field) {
                 if ($this->product->customization_required = $customization_field['required']) {
                     break;
                 }
             }
         }
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $product_options = ProductOption::getProductOptions($this->context->language->id);
         foreach ($product_options as &$product_option) {
             if (isset($this->product->id) && !empty($this->product->id)) {
                 $product_option['selected'] = Db::getInstance()->getValue("SELECT id_product_option AS `selected` FROM " . _DB_PREFIX_ . "product_option_product\n                                WHERE id_product={$this->product->id} AND id_product_option={$product_option['id_product_option']}");
                 $product_option['amount'] = Db::getInstance()->getValue("SELECT amount AS `amount` FROM " . _DB_PREFIX_ . "product_option_product\n                                WHERE id_product={$this->product->id} AND id_product_option={$product_option['id_product_option']}");
             } else {
                 $product_option['selected'] = null;
             }
         }
         $accessories = $this->product->getAccessories($this->context->language->id);
         if ($this->product->cache_is_pack || count($accessories)) {
             $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
         }
         if ($this->product->customizable) {
             $customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
         }
         $this->context->smarty->assign(array('product_options' => count($product_options) ? $product_options : null, 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
Example #9
0
<?php

include dirname(__FILE__) . '/../../debug.php';
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/blockcompare.php';
$errors = array();
Tools::safePostVars();
include_once dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/../../debug-style.php';
$m = new BlockCompare();
$m->hookTop(array());
$products = $compare_cart->getProducts();
$smarty->assign(array('products' => $products));
$features = array();
foreach ($products as $product) {
    $product = new Product($product['id']);
    $product_features = $product->getFrontFeatures(intval($cookie->id_lang));
    foreach ($product_features as $product_feature) {
        if (!isset($features[$product_feature['name']])) {
            $features[$product_feature['name']] = array();
        }
        $features[$product_feature['name']][$product->id] = $product_feature['value'];
    }
}
$smarty->assign(array('features' => $features));
$block = new BlockCompare();
echo $block->display(dirname(__FILE__) . '/blockcompare.php', 'comparecart.tpl');
include_once dirname(__FILE__) . '/../../footer.php';
 /**
  * Convert the entities data into an xml object and return the xml object as a string
  *
  * @param array $aEntity Entity data
  */
 public function formatEntityToXML($aEntity)
 {
     global $link;
     $sReturn = '';
     $dom = new DOMDocument('1.0', 'utf-8');
     $oProduct = new Product((int) $aEntity['id_product'], true);
     if ((int) $oProduct->quantity < (int) $this->productMinQuantity) {
         $this->nbEntitiesTreated--;
         $this->nbEntities--;
         return ' ';
     }
     $ps_tax = (int) Configuration::get('PS_TAX');
     foreach ($this->aLanguages as $aLanguage) {
         $id_lang = (int) $aLanguage['id_lang'];
         // Set the root of the XML
         $root = $dom->createElement($this->sEntity);
         $dom->appendChild($root);
         //$root->setAttribute('timestamp', date('c',strtotime($oProduct->date_add)));
         $root->setAttribute('timestamp', (int) strtotime($oProduct->date_add));
         $id = $dom->createElement('id', (int) $oProduct->id);
         $root->appendChild($id);
         $profile = $dom->createElement('profile', $id_lang);
         $root->appendChild($profile);
         $name = $dom->createElement('name');
         $name->appendChild($dom->createCDATASection($oProduct->name[$id_lang]));
         $root->appendChild($name);
         $oCategory = new Category((int) $oProduct->id_category_default);
         $aCategories = $oCategory->getParentsCategories($id_lang);
         if (is_array($aCategories) && count($aCategories) > 0) {
             foreach ($aCategories as $aCategory) {
                 $oCategoryTmp = new Category((int) $aCategory['id_category'], $id_lang);
                 if (!empty($oCategoryTmp->name)) {
                     $genre = $dom->createElement('genre');
                     $genre->appendChild($dom->createCDATASection($oCategoryTmp->name));
                     $root->appendChild($genre);
                 }
                 unset($oCategoryTmp);
             }
         }
         unset($aCategories);
         unset($oCategory);
         if (!empty($oProduct->ean13)) {
             $ean = $dom->createElement('ean');
             $ean->appendChild($dom->createCDATASection($oProduct->ean13));
             $root->appendChild($ean);
         }
         $price = $dom->createElement('price', number_format($oProduct->getPrice($ps_tax), 2, '.', ''));
         $root->appendChild($price);
         if (isset($oProduct->tags[$id_lang]) && ($aTags = $oProduct->tags[$id_lang])) {
             $tag = $dom->createElement('tag');
             $tag->appendChild($dom->createCDATASection(join(',', $aTags)));
             $root->appendChild($tag);
         }
         $sDesc = trim(strip_tags($oProduct->description[$id_lang]));
         if ($this->descInExport && !empty($sDesc)) {
             $description = $dom->createElement('description');
             $description->appendChild($dom->createCDATASection($sDesc));
             $root->appendChild($description);
         }
         if (!empty($oProduct->id_manufacturer)) {
             $supplierid = $dom->createElement('supplierid', (int) $oProduct->id_manufacturer);
             $root->appendChild($supplierid);
         }
         $recommendable = $dom->createElement('recommendable', in_array((int) $oProduct->id, $this->aProductsNotRecommendable) ? 'false' : 'true');
         $root->appendChild($recommendable);
         $searchable = $dom->createElement('searchable', in_array((int) $oProduct->id, $this->aProductsNotSearchable) ? 'false' : 'true');
         $root->appendChild($searchable);
         // Set product URL
         $attribute = $dom->createElement('attribute');
         $root->appendChild($attribute);
         $attName = $dom->createElement('attName', 'producturl');
         $attribute->appendChild($attName);
         $attValue = $dom->createElement('attValue');
         $attValue->appendChild($dom->createCDATASection($link->getProductLink((int) $oProduct->id, $oProduct->link_rewrite[$id_lang], Category::getLinkRewrite((int) $oProduct->id_category_default, $id_lang), NULL, $id_lang)));
         $attribute->appendChild($attValue);
         // Set product picture
         if ($this->imageInExport) {
             $attribute = $dom->createElement('attribute');
             $root->appendChild($attribute);
             $attName = $dom->createElement('attName', 'imageurl');
             $attribute->appendChild($attName);
             $aCover = $oProduct->getCover((int) $oProduct->id);
             $attValue = $dom->createElement('attValue');
             $attValue->appendChild($dom->createCDATASection($link->getImageLink($oProduct->link_rewrite[$id_lang], (int) $aCover['id_image'], 'large')));
             $attribute->appendChild($attValue);
         }
         // Set combinations
         $aProductCombinations = $oProduct->getAttributeCombinaisons($id_lang);
         if (sizeof($aProductCombinations)) {
             foreach ($aProductCombinations as $aProductCombination) {
                 if (!is_array($this->aAttributesGroupsIds) || in_array((int) $aProductCombination['id_attribute_group'], $this->aAttributesGroupsIds)) {
                     $attribute = $dom->createElement('attribute');
                     $root->appendChild($attribute);
                     $attName = $dom->createElement('attName');
                     $attName->appendChild($dom->createCDATASection($aProductCombination['group_name']));
                     $attribute->appendChild($attName);
                     $attValue = $dom->createElement('attValue');
                     $attValue->appendChild($dom->createCDATASection($aProductCombination['attribute_name']));
                     $attribute->appendChild($attValue);
                 }
             }
         }
         unset($aProductCombinations);
         // Set features
         $aProductFeatures = $oProduct->getFrontFeatures($id_lang);
         if (sizeof($aProductFeatures)) {
             foreach ($aProductFeatures as $aProductFeature) {
                 if (!is_array($this->aFeaturesIds) || in_array((int) $aProductFeature['id_feature'], $this->aFeaturesIds)) {
                     $attribute = $dom->createElement('attribute');
                     $root->appendChild($attribute);
                     $attName = $dom->createElement('attName');
                     $attName->appendChild($dom->createCDATASection($aProductFeature['name']));
                     $attribute->appendChild($attName);
                     $attValue = $dom->createElement('attValue');
                     $attValue->appendChild($dom->createCDATASection($aProductFeature['value']));
                     $attribute->appendChild($attValue);
                 }
             }
         }
         unset($aProductFeatures);
         $aAccessories = Product::getAccessoriesLight($id_lang, (int) $oProduct->id);
         if (sizeof($aAccessories)) {
             foreach ($aAccessories as $aAccessory) {
                 $attribute = $dom->createElement('attribute');
                 $root->appendChild($attribute);
                 $attName = $dom->createElement('attName');
                 $attName->appendChild($dom->createCDATASection('accessory'));
                 $attribute->appendChild($attName);
                 $attValue = $dom->createElement('attValue');
                 $attValue->appendChild($dom->createCDATASection($aAccessory['reference']));
                 $attribute->appendChild($attValue);
             }
         }
         unset($aAccessories);
         $sReturn .= $dom->saveXML($root);
     }
     unset($dom);
     unset($oProduct);
     return $sReturn;
 }