public function viewsupplier() { global $cookie; $supplier = $this->loadObject(); echo '<h2>' . $supplier->name . '</h2>'; $products = $supplier->getProductsLite(intval($cookie->id_lang)); echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>'; foreach ($products as $product) { $product = new Product($product['id_product'], false, intval($cookie->id_lang)); echo '<hr />'; if (!$product->hasAttributes()) { echo ' <table border="0" cellpadding="0" cellspacing="0" class="table width3"> <tr> <th><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></th> ' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . ' ' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . ' ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . ' </tr> </table>'; } else { echo ' <h3><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></h3> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th>' . $this->l('Attribute name') . '</th> <th width="80">' . $this->l('Reference') . '</th> <th width="80">' . $this->l('EAN13') . '</th> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . ' </tr>'; /* Build attributes combinaisons */ $combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang)); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); } $irow = 0; foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; foreach ($product_attribute['attributes'] as $attribute) { $list .= $attribute[0] . ' - ' . $attribute[1] . ', '; } $list = rtrim($list, ', '); echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' > <td>' . stripslashes($list) . '</td> <td>' . $product_attribute['reference'] . '</td> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td>' : '') . ' <td class="right">' . $product_attribute['quantity'] . '</td> </tr>'; } unset($combArray); echo '</table>'; echo '</td></tr></table>'; } } }
protected function getData($layers) { global $cookie; if ($this->_option == 42) { $products = $this->getProducts(intval($cookie->id_lang)); foreach ($products as $product) { $this->_values[0][] = $product['reference']; $this->_values[1][] = $product['name']; $this->_values[2][] = $product['quantity']; $this->_legend[] = $product['id_product']; } } elseif ($this->_option != 3) { $this->setDateGraph($layers, true); } else { $product = new Product($this->_id_product, false, (int) $this->getLang()); $combArray = array(); $assocNames = array(); $combinaisons = $product->getAttributeCombinaisons((int) $this->getLang()); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']][] = array('group' => $combinaison['group_name'], 'attr' => $combinaison['attribute_name']); } foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; foreach ($product_attribute as $attribute) { $list .= trim($attribute['group']) . ' - ' . trim($attribute['attr']) . ', '; } $list = rtrim($list, ', '); $assocNames[$id_product_attribute] = $list; } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($this->_query); foreach ($result as $row) { $this->_values[] = $row['total']; $this->_legend[] = @$assocNames[$row['product_attribute_id']]; } } }
public function viewmanufacturer() { global $cookie; $manufacturer = $this->loadObject(); echo '<h2>' . $manufacturer->name . '</h2>'; $products = $manufacturer->getProductsLite(intval($cookie->id_lang)); $addresses = $manufacturer->getAddresses(intval($cookie->id_lang)); echo '<h3>' . $this->l('Total addresses:') . ' ' . sizeof($addresses) . '</h3>'; echo '<hr />'; foreach ($addresses as $addresse) { echo ' <h3></h3> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th><b>' . $addresse['firstname'] . ' ' . $addresse['lastname'] . '</b></th> </tr> <tr> <td> <div style="padding:5px; float:left; width:350px;"> ' . $addresse['address1'] . '<br /> ' . ($addresse['address2'] ? $addresse['address2'] . '<br />' : '') . ' ' . $addresse['postcode'] . ' ' . $addresse['city'] . '<br /> ' . ($addresse['state'] ? $addresse['state'] . '<br />' : '') . ' <b>' . $addresse['country'] . '</b><br /> </div> <div style="padding:5px; float:left;"> ' . ($addresse['phone'] ? $addresse['phone'] . '<br />' : '') . ' ' . ($addresse['phone_mobile'] ? $addresse['phone_mobile'] . '<br />' : '') . ' </div> ' . ($addresse['other'] ? '<div style="padding:5px; clear:both;"><br /><i>' . $addresse['other'] . '</i></div>' : '') . ' </td> </tr> </table>'; } if (!sizeof($addresses)) { echo 'No address for this manufacturer.'; } echo '<br /><br />'; echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>'; foreach ($products as $product) { $product = new Product($product['id_product'], false, intval($cookie->id_lang)); echo '<hr />'; if (!$product->hasAttributes()) { echo ' <table border="0" cellpadding="0" cellspacing="0" class="table width3"> <tr> <th>' . $product->name . '</th> ' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . ' ' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . ' ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . ' </tr> </table>'; } else { echo ' <h3>' . $product->name . '</h3> <table> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th>' . $this->l('Attribute name') . '</th> <th width="80">' . $this->l('Reference') . '</th> <th width="80">' . $this->l('EAN13') . '</th> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . ' </tr>'; /* Build attributes combinaisons */ $combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang)); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); } $irow = 0; foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; foreach ($product_attribute['attributes'] as $attribute) { $list .= $attribute[0] . ' - ' . $attribute[1] . ', '; } $list = rtrim($list, ', '); echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' > <td>' . stripslashes($list) . '</td> <td>' . $product_attribute['reference'] . '</td> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td>' : '') . ' <td class="right">' . $product_attribute['quantity'] . '</td> </tr>'; } unset($combArray); echo '</table>'; } } }
protected function getData($layers) { if ($this->_option != 3) { $this->setDateGraph($layers, true); } else { $product = new Product($this->_id_product, false, intval($this->getLang())); $combArray = array(); $assocNames = array(); $combinaisons = $product->getAttributeCombinaisons(intval($this->getLang())); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']][] = array('group' => $combinaison['group_name'], 'attr' => $combinaison['attribute_name']); } foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; foreach ($product_attribute as $attribute) { $list .= trim($attribute['group']) . ' - ' . trim($attribute['attr']) . ', '; } $list = rtrim($list, ', '); $assocNames[$id_product_attribute] = $list; } $result = Db::getInstance()->ExecuteS($this->_query); foreach ($result as $row) { $this->_values[] = $row['total']; $this->_legend[] = @$assocNames[$row['product_attribute_id']]; } } }
public function viewmanufacturer() { global $cookie; if (!($manufacturer = $this->loadObject())) { return; } echo '<h2>' . $manufacturer->name . '</h2>'; $products = $manufacturer->getProductsLite((int) $cookie->id_lang); $addresses = $manufacturer->getAddresses((int) $cookie->id_lang); echo '<h3>' . $this->l('Total addresses:') . ' ' . sizeof($addresses) . '</h3>'; echo '<hr />'; foreach ($addresses as $addresse) { echo ' <h3></h3> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th><b>' . $addresse['firstname'] . ' ' . $addresse['lastname'] . '</b></th> </tr> <tr> <td> <div style="padding:5px; float:left; width:350px;"> ' . $addresse['address1'] . '<br /> ' . ($addresse['address2'] ? $addresse['address2'] . '<br />' : '') . ' ' . $addresse['postcode'] . ' ' . $addresse['city'] . '<br /> ' . ($addresse['state'] ? $addresse['state'] . '<br />' : '') . ' <b>' . $addresse['country'] . '</b><br /> </div> <div style="padding:5px; float:left;"> ' . ($addresse['phone'] ? $addresse['phone'] . '<br />' : '') . ' ' . ($addresse['phone_mobile'] ? $addresse['phone_mobile'] . '<br />' : '') . ' </div> ' . ($addresse['other'] ? '<div style="padding:5px; clear:both;"><br /><i>' . $addresse['other'] . '</i></div>' : '') . ' </td> </tr> </table>'; } if (!sizeof($addresses)) { echo 'No address for this manufacturer.'; } echo '<br /><br />'; echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>'; foreach ($products as $product) { $product = new Product($product['id_product'], false, (int) $cookie->id_lang); echo '<hr />'; if (!$product->hasAttributes()) { echo ' <div style="float:right;"> <a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button">' . $this->l('Edit') . '</a> <a href="?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button" onclick="return confirm(\'' . $this->l('Delete item #', __CLASS__, TRUE) . $product->id . ' ?\');">' . $this->l('Delete') . '</a> </div> <table border="0" cellpadding="0" cellspacing="0" class="table width3"> <tr> <th>' . $product->name . '</th> ' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . ' ' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . ' ' . (!empty($product->upc) ? '<th width="120">' . $this->l('UPC:') . ' ' . $product->upc . '</th>' : '') . ' ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . ' </tr> </table>'; } else { echo ' <div style="float:right;"> <a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button">' . $this->l('Edit') . '</a> <a href="?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button" onclick="return confirm(\'' . $this->l('Delete item #', __CLASS__, TRUE) . $product->id . ' ?\');">' . $this->l('Delete') . '</a> </div> <h3><a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">' . $product->name . '</a></h3> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th>' . $this->l('Attribute name') . '</th> <th width="80">' . $this->l('Reference') . '</th> <th width="80">' . $this->l('EAN13') . '</th> <th width="80">' . $this->l('UPC') . '</th> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . ' </tr>'; /* Build attributes combinaisons */ $combinaisons = $product->getAttributeCombinaisons((int) $cookie->id_lang); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); } $irow = 0; foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; foreach ($product_attribute['attributes'] as $attribute) { $list .= $attribute[0] . ' - ' . $attribute[1] . ', '; } $list = rtrim($list, ', '); echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' > <td>' . stripslashes($list) . '</td> <td>' . $product_attribute['reference'] . '</td> ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td><td>' . $product_attribute['upc'] . '</td>' : '') . ' <td class="right">' . $product_attribute['quantity'] . '</td> </tr>'; } unset($combArray); echo '</table>'; } } }
private function getAlertCategories() { $alert = ''; $sql_getCatNonMultiSku = "SELECT * FROM " . _DB_PREFIX_ . "ebay_category_configuration AS ecc\r\n\t\t\tINNER JOIN " . _DB_PREFIX_ . "ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category"; $CatNonMultiSku = Db::getInstance()->ExecuteS($sql_getCatNonMultiSku); $catWithProblem = array(); foreach ($CatNonMultiSku as $cat) { if ($cat['is_multi_sku'] != 1 && $this->findIfCategoryParentIsMultiSku($cat['id_category_ref']) != 1) { $categorie = new Category($cat['id_category']); $products = $categorie->getProductsWs($this->id_lang, 0, 300); $catProblem = 0; foreach ($products as $productArray) { $product = new Product($productArray['id']); $combinations = $product->getAttributeCombinaisons($this->id_lang); if (count($combinations) > 0 && $catProblem == 0) { $catWithProblem[] = $cat['name']; $catProblem = 1; } } } } $var = ''; $j = 0; foreach ($catWithProblem as $cat) { if ($j != 0) { $var .= ', '; } $var .= $cat; $j++; } if (count($catWithProblem) > 0) { if (count($catWithProblem == 1)) { $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } else { $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } } return $alert; }
function addProducts($client, $ids = array()) { //update currency // update_currency(); $default_tz = date_default_timezone_get(); date_default_timezone_set('UTC'); $category = new Category(1, 1); $sql = "select p.id_product, DATEDIFF(NOW(), p.`date_add`) as 'age'\n from ps_product p\n where p.price > 0 and p.active = 1"; $productScores = array(); $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($products as $product) { $productScores[$product['id_product']] = array('age' => $product['age'], 'week_sold' => 0, 'month_sales' => 0, 'year_sales' => 0); } $sql = "select p.`id_product`, sum(od.product_quantity) as 'quantity'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 \n and p.active = 1\n and o.date_add > now() - INTERVAL 7 DAY\n group by p.id_product"; $week_quantities = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($week_quantities as $week_quantity) { $productScores[$week_quantity['id_product']]['week_sold'] = $week_quantity['quantity']; } $sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'month_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 30 DAY\n group by p.id_product"; $month_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($month_sales as $month_sale) { $productScores[$month_sale['id_product']]['month_sales'] = $month_sale['month_revenue']; } $sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'year_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 365 DAY\n group by p.id_product"; $year_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($year_sales as $year_sale) { $productScores[$year_sale['id_product']]['year_sales'] = $year_sale['year_revenue']; } foreach ($products as $product) { $productScores[$product['id_product']]['score'] = getWeekSalesScore($productScores[$product['id_product']]['week_sold']) + getAgeScore($productScores[$product['id_product']]['age']) + getMonthScore($productScores[$product['id_product']]['month_sales']) + getYearScore($productScores[$product['id_product']]['year_sales']); } $docs = array(); $link = new Link(); $count = 0; $update = $client->createUpdate(); foreach ($products as $product) { if (!empty($ids) && !in_array((int) $product['id_product'], $ids)) { continue; } $productObj = new Product((int) $product['id_product'], true, 1); print_r('\\n' . 'reindexing ' . $product['id_product']); if (!$productObj->active) { deleteProduct($productObj->id, $client); continue; } $doc = $update->createDocument(); $doc->id_product = $productObj->id; $doc->reference = $productObj->reference; $doc->name = $productObj->name; $doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description); $doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->brand_id = $productObj->id_manufacturer; $doc->brand_name = $productObj->manufacturer_name; $doc->style_tips = $productObj->description_short; $doc->alphaNameSort = $productObj->name; $dbresult = $productObj->getWsCategories(); $catIds = array(); foreach ($dbresult as $catIdRow) { $catIds[] = $catIdRow['id']; } $category_names = array(); foreach ($catIds as $catID) { $category = new Category((int) $catID); $category_names[] = $category->getName(1); } $doc->cat_name = $category_names; $doc->cat_id = $catIds; $doc->tags = $productObj->getTags(1); $doc->shipping_sla = $productObj->shipping_sla ? $productObj->shipping_sla : 0; $doc->weight = $productObj->weight ? $productObj->weight : 0.5; if (isset($productObj->work_type)) { $doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : ''); } if (isset($productObj->garment_type)) { $doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : ''); } if (isset($productObj->blouse_length)) { $doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : ''; } $doc->height = $productObj->height; $doc->width = $productObj->width; $atributeQty = Attribute::getAttributeQty($productObj->id); if ($productObj->quantity > 0 || $atributeQty > 0) { $doc->inStock = true; } else { $doc->inStock = false; } $doc->isPlusSize = $productObj->is_plussize ? true : false; $doc->isRTS = $productObj->is_rts ? true : false; $doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0); //Indian Price $doc->offer_price_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, true, 1, false, NULL, NULL, IND_ADDRESS_ID); $doc->offer_price_in_rs = Tools::convertPrice($doc->offer_price_in, 4); $doc->mrp_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, false, 1, false, NULL, NULL, IND_ADDRESS_ID); if ($doc->mrp_in > $doc->offer_price_in) { $doc->discount_in = Tools::ps_round(($doc->mrp_in - $doc->offer_price_in) / $doc->mrp_in * 100); } //Worldwide Price $doc->offer_price = $productObj->getPrice(); $doc->offer_price_rs = Tools::convertPrice($doc->offer_price, 4); $doc->mrp = $productObj->getPriceWithoutReduct(); if ($doc->mrp > $doc->offer_price) { $doc->discount = Tools::ps_round(($doc->mrp - $doc->offer_price) / $doc->mrp * 100); } $date = DateTime::createFromFormat('Y-m-d H:i:s', $productObj->date_add); $doc->date_add = $date->format("Y-m-d\\TG:i:s\\Z"); $doc->product_link = $productObj->getLink(); $idImage = $productObj->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $doc->image_link_list = $link->getImageLink($productObj->link_rewrite, $idImage, 'list'); $doc->image_link_medium = $link->getImageLink($productObj->link_rewrite, $idImage, 'medium'); $doc->image_link_large = $link->getImageLink($productObj->link_rewrite, $idImage, 'large'); $images = $productObj->getImages(1); $productImages = array(); foreach ($images as $k => $image) { $productImages[] = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'large'); } $doc->image_links = $productImages; $doc->sales = $productScores[$product['id_product']]['score']; $productObj->fabric = trim($productObj->fabric); $productObj->fabric = preg_replace('/\\s+/', '-', $productObj->fabric); $doc->fabric = strtolower($productObj->fabric); $doc->is_customizable = $productObj->is_customizable; if (isset($productObj->generic_color) && !empty($productObj->generic_color)) { $colors = explode(',', $productObj->generic_color); $indexed_colors = array(); foreach ($colors as $color) { $indexed_colors[] = strtolower(preg_replace('/\\s+/', '-', trim($color))); } $doc->color = $indexed_colors; } if (isset($productObj->stone) && !empty($productObj->stone)) { $stones = explode(',', $productObj->stone); $indexed_stones = array(); foreach ($stones as $stone) { $indexed_stones[] = strtolower(preg_replace('/\\s+/', '-', trim($stone))); } $doc->stone = $indexed_stones; } if (isset($productObj->plating) && !empty($productObj->plating)) { $platings = explode(',', $productObj->plating); $indexed_platings = array(); foreach ($platings as $plating) { $indexed_platings[] = strtolower(preg_replace('/\\s+/', '-', trim($plating))); } $doc->plating = $indexed_platings; } if (isset($productObj->material) && !empty($productObj->material)) { $materials = explode(',', $productObj->material); $indexed_materials = array(); foreach ($materials as $material) { $indexed_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($material))); } $doc->material = $indexed_materials; } if (isset($productObj->look) && !empty($productObj->look)) { $looks = explode(',', $productObj->look); $indexed_looks = array(); foreach ($looks as $look) { $indexed_looks[] = strtolower(preg_replace('/\\s+/', '-', trim($look))); } $doc->look = $indexed_looks; } if (isset($productObj->handbag_occasion) && !empty($productObj->handbag_occasion)) { $handbag_occasions = explode(',', $productObj->handbag_occasion); $indexed_handbag_occasions = array(); foreach ($handbag_occasions as $handbag_occasion) { $indexed_handbag_occasions[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_occasion))); } $doc->handbag_occasion = $indexed_handbag_occasions; } if (isset($productObj->handbag_style) && !empty($productObj->handbag_style)) { $handbag_styles = explode(',', $productObj->handbag_style); $indexed_handbag_styles = array(); foreach ($handbag_styles as $handbag_style) { $indexed_handbag_styles[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_style))); } $doc->handbag_style = $indexed_handbag_styles; } if (isset($productObj->handbag_material) && !empty($productObj->handbag_material)) { $handbag_materials = explode(',', $productObj->handbag_material); $indexed_handbag_materials = array(); foreach ($handbag_materials as $handbag_material) { $indexed_handbag_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_material))); } $doc->handbag_material = $indexed_handbag_materials; } $combinaisons = $productObj->getAttributeCombinaisons(1); $indexed_sizes = array(); foreach ($combinaisons as $k => $combinaison) { if ($combinaison['group_name'] == 'size' || $combinaison['group_name'] == 'Size') { $indexed_sizes[] = $combinaison['attribute_name']; } } $doc->size = $indexed_sizes; $doc->cashback_percentage = $productObj->cashback_percentage; $docs[] = $doc; if (++$count == 300) { $update->addDocuments($docs); $result = $client->update($update); echo 'Update query executed' . PHP_EOL; echo 'Query status: ' . $result->getStatus() . PHP_EOL; echo 'Query time: ' . $result->getQueryTime() . PHP_EOL; $count = 0; $docs = array(); $update = $client->createUpdate(); } } $update->addDocuments($docs); date_default_timezone_set($default_tz); $result = $client->update($update); $sql = "update ps_product set indexed = 1 where indexed = 0"; Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); }
public static function getMultiVarToNonMultiSku($ebay_profile, $context) { $cat_with_problem = array(); $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category WHERE ecc.id_ebay_profile = ' . (int) $ebay_profile->id . ' GROUP BY name'; foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) { if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref'], $ebay_profile->ebay_site_id) != 1) { $catProblem = 0; $category = new Category($cat['id_category']); $ebay_country = EbayCountrySpec::getInstanceByKey($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT')); $products = $category->getProductsWs($ebay_country->getIdLang(), 0, 300); foreach ($products as $product_ar) { $product = new Product($product_ar['id']); $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($context->cookie->id_lang) : $product->getAttributeCombinaisons($context->cookie->id_lang); if (count($combinations) > 0 && !$catProblem) { $cat_with_problem[] = $cat['name']; $catProblem = 1; } } } } return $cat_with_problem; }
private function _getAlertCategories() { $alert = ''; $cat_with_problem = array(); $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category'; foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) { if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref']) != 1) { $catProblem = 0; $category = new Category($cat['id_category']); $products = $category->getProductsWs($this->ebay_country->getIdLang(), 0, 300); foreach ($products as $product_ar) { $product = new Product($product_ar['id']); $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang); if (count($combinations) > 0 && !$catProblem) { $cat_with_problem[] = $cat['name']; $catProblem = 1; } } } } $var = implode(', ', $cat_with_problem); if (count($cat_with_problem) > 0) { if (count($cat_with_problem == 1)) { // RAPH: pb here in the test. Potential typo $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } else { $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } } return $alert; }
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; }
/** * @param Solarium_Query_Update $update * @param Link $link * @param Product $productObj * @return Solarium_Document_ReadWrite */ private static function getProductDoc($update, $link, $productObj) { $doc = $update->createDocument(); $doc->id_product = $productObj->id; $doc->reference = $productObj->reference; $doc->name = $productObj->name; //$doc->description = $productObj->description; $doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description); $doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->brand_id = $productObj->id_manufacturer; $doc->brand_name = $productObj->manufacturer_name; $doc->style_tips = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->alphaNameSort = $productObj->name; $dbresult = $productObj->getWsCategories(); $catIds = array(); foreach ($dbresult as $catIdRow) { $catIds[] = $catIdRow['id']; } $category_names = array(); foreach ($catIds as $catID) { $category = new Category((int) $catID); $category_names[] = $category->getName(1); } $doc->cat_name = $category_names; $doc->cat_id = $catIds; $doc->tags = $productObj->getTags(1); $doc->shipping_sla = $productObj->shipping_sla; $doc->weight = $productObj->weight ? $productObj->weight : 0.5; $doc->cashback_percentage = $productObj->cashback_percentage; if (isset($productObj->work_type)) { $doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : ''); } if (isset($productObj->garment_type)) { $doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : ''); } if (isset($productObj->blouse_length)) { $doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : ''; } $doc->height = $productObj->height; $doc->width = $productObj->width; $atributeQty = Attribute::getAttributeQty($productObj->id); if ($productObj->quantity > 0 || $atributeQty > 0) { $doc->inStock = true; } else { $doc->inStock = false; } $doc->isPlusSize = $productObj->is_plussize ? true : false; $doc->isRTS = $productObj->is_rts ? true : false; $doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0); $date = DateTime::createFromFormat('Y-m-d H:i:s', $productObj->date_add); $doc->date_add = $date->format("Y-m-d\\TG:i:s\\Z"); $productObj->fabric = trim($productObj->fabric); $productObj->fabric = preg_replace('/\\s+/', '-', $productObj->fabric); $doc->fabric = strtolower($productObj->fabric); $doc->is_customizable = $productObj->is_customizable; if (isset($productObj->generic_color) && !empty($productObj->generic_color)) { $colors = explode(',', $productObj->generic_color); $indexed_colors = array(); foreach ($colors as $color) { $indexed_colors[] = strtolower(preg_replace('/\\s+/', '-', trim($color))); } $doc->color = $indexed_colors; } if (isset($productObj->stone) && !empty($productObj->stone)) { $stones = explode(',', $productObj->stone); $indexed_stones = array(); foreach ($stones as $stone) { $indexed_stones[] = strtolower(preg_replace('/\\s+/', '-', trim($stone))); } $doc->stone = $indexed_stones; } if (isset($productObj->plating) && !empty($productObj->plating)) { $platings = explode(',', $productObj->plating); $indexed_platings = array(); foreach ($platings as $plating) { $indexed_platings[] = strtolower(preg_replace('/\\s+/', '-', trim($plating))); } $doc->plating = $indexed_platings; } if (isset($productObj->material) && !empty($productObj->material)) { $materials = explode(',', $productObj->material); $indexed_materials = array(); foreach ($materials as $material) { $indexed_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($material))); } $doc->material = $indexed_materials; } if (isset($productObj->look) && !empty($productObj->look)) { $looks = explode(',', $productObj->look); $indexed_looks = array(); foreach ($looks as $look) { $indexed_looks[] = strtolower(preg_replace('/\\s+/', '-', trim($look))); } $doc->look = $indexed_looks; } if (isset($productObj->handbag_occasion) && !empty($productObj->handbag_occasion)) { $handbag_occasions = explode(',', $productObj->handbag_occasion); $indexed_handbag_occasions = array(); foreach ($handbag_occasions as $handbag_occasion) { $indexed_handbag_occasions[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_occasion))); } $doc->handbag_occasion = $indexed_handbag_occasions; } if (isset($productObj->handbag_style) && !empty($productObj->handbag_style)) { $handbag_styles = explode(',', $productObj->handbag_style); $indexed_handbag_styles = array(); foreach ($handbag_styles as $handbag_style) { $indexed_handbag_styles[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_style))); } $doc->handbag_style = $indexed_handbag_styles; } if (isset($productObj->handbag_material) && !empty($productObj->handbag_material)) { $handbag_materials = explode(',', $productObj->handbag_material); $indexed_handbag_materials = array(); foreach ($handbag_materials as $handbag_material) { $indexed_handbag_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_material))); } $doc->handbag_material = $indexed_handbag_materials; } $combinaisons = $productObj->getAttributeCombinaisons(1); $indexed_sizes = array(); foreach ($combinaisons as $k => $combinaison) { if ($combinaison['group_name'] == 'size' || $combinaison['group_name'] == 'Size') { $indexed_sizes[] = $combinaison['attribute_name']; } } $doc->size = $indexed_sizes; //Indian Price $doc->offer_price_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, true, 1, false, NULL, NULL, IND_ADDRESS_ID); $doc->offer_price_in_rs = Tools::convertPrice($doc->offer_price_in, 4); $doc->mrp_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, false, 1, false, NULL, NULL, IND_ADDRESS_ID); if ($doc->mrp_in > $doc->offer_price_in) { $doc->discount_in = Tools::ps_round(($doc->mrp_in - $doc->offer_price_in) / $doc->mrp_in * 100); } //Worldwide Price $doc->offer_price = $productObj->getPrice(); $doc->offer_price_rs = Tools::convertPrice($doc->offer_price, 4); $doc->mrp = $productObj->getPriceWithoutReduct(); if ($doc->mrp > $doc->offer_price) { $doc->discount = Tools::ps_round(($doc->mrp - $doc->offer_price) / $doc->mrp * 100); } $doc->product_link = $productObj->getLink(); $idImage = $productObj->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $doc->image_link_list = $link->getImageLink($productObj->link_rewrite, $idImage, 'list'); $doc->image_link_medium = $link->getImageLink($productObj->link_rewrite, $idImage, 'medium'); $doc->image_link_large = $link->getImageLink($productObj->link_rewrite, $idImage, 'large'); $images = $productObj->getImages(1); $productImages = array(); foreach ($images as $k => $image) { $productImages[] = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'large'); } $doc->image_links = $productImages; return $doc; }
/** * 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; }