public function initContent() { parent::initContent(); $id = $_GET['id']; $id_lang = $this->context->language->id; $product = new Product((int) $id); $link = new Link(); $url = $link->getProductLink($product); $features = Db::getInstance()->ExecuteS(' SELECT fl.name feature_name, fvl.value feature_value FROM ' . _DB_PREFIX_ . 'feature_product fp LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' ) LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ') WHERE fp.id_product=' . $id); // print_r($features); $images = Image::getImages((int) $id_lang, (int) $product->id); //Limitamos el numero de fotos a cuatro solamente while (count($images) > 3) { $var = array_pop($images); } $this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND'))); $html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl'); $dompdf = new DOMPDF(); $dompdf->set_option('enable_remote', TRUE); $dompdf->load_html($html); $dompdf->set_paper('a4', 'portrait'); $dompdf->render(); $dompdf->stream('producto'); //$this->setTemplate('custom_template_content.tpl'); //file_put_contents($filename, $dompdf->output()); //$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty); //$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg'; //$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); //$pdf->render(); }
public function sendQuestion() { if (Tools::getValue('enviar_mensaje')) { $params = array(); $params['nombre'] = pSQL(Tools::getValue('nombre', '')); $params['email'] = pSQL(Tools::getValue('email', '')); $params['ciudad'] = pSQL(Tools::getValue('ciudad', '')); $params['provincia'] = pSQL(Tools::getValue('provincia', '')); $params['consulta'] = pSQL(Tools::getValue('consulta', '')); $params['id_producto'] = (int) Tools::getValue('id_producto', 0); $params['date_add'] = date('Y-m-d H:i:s', strtotime('now')); $params['validado'] = 0; DB::getInstance()->insert('lgconsultas', $params); $id_consulta = Db::getInstance()->Insert_ID(); if ($id_consulta) { $consulta = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'lgconsultas` WHERE id_consulta=' . (int) $id_consulta); $producto = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'product_lang WHERE id_product=' . (int) $consulta['id_producto'] . ' AND id_lang=' . (int) Configuration::get('PS_LANG_DEFAULT')); $enlace = new Link(); $urlproducto = $enlace->getProductLink($consulta['id_producto']); $templateVars = array('id_consulta' => $id_consulta, '{consulta}' => pSQL($consulta['consulta']), '{nombre}' => pSQL($consulta['nombre']), '{email}' => pSQL($consulta['email']), '{provincia}' => pSQL($consulta['provincia']), '{ciudad}' => pSQL($consulta['ciudad']), '{producto}' => $producto, '{urlproducto}' => $urlproducto); if (!Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'consulta_enviada', $this->l('You have received a new question about a product'), $templateVars, Configuration::get('LG_CONSULTAS_EMAIL'), null, Configuration::get('LG_CONSULTAS_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'lgconsultas/mails/')) { $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while sending your question')); } else { $out = array('status' => 'ok', 'msg' => $this->l('Your question has been sent')); } } else { $out = array('status' => 'nok', 'msg' => $this->l('An error occurred while trying to add your question')); } echo Tools::jsonEncode($out); die; } }
protected function _prepareHook($params) { $languages = Language::getLanguages(true, $this->context->shop->id); if (!count($languages)) { return false; } $link = new Link(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) { $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } $this->smarty->assign('lang_rewrite_urls', $default_rewrite); } return true; }
public function ajaxProcessGetTable() { $this->ormprod = new egormprod(); $list = $this->ormprod->getProductList(0, false, false); $link = new Link(); $output = ""; foreach ($list as $row) { $output .= "<tr><td>-</td>"; $output .= "<td>" . $row['id_product'] . "</td>"; $output .= "<td><span>" . $row['product_sname'] . "</span><br><span style='font-size: 8px;'><a href='" . $row['product_url'] . "'>" . $row['product_url'] . "</a></span></td>"; $output .= "<td><span>" . $row['name'] . "</span><br><span style='font-size: 8px;'><a href='" . $link->getProductLink($row['id_product']) . "'>" . $link->getProductLink($row['id_product']) . "</a></span></td>"; $output .= "<td>" . $row['product_attrgroup'] . "</td>"; $output .= "<td>" . $row['price_discount'] . "</td>"; $output .= "<td>" . $row['dname'] . "</td>"; $output .= "<td><a href='#' onclick='UpdateRow(this);return(false);'>R</a>"; $output .= " <a href='" . Context::getContext()->link->getAdminLink('AdminProducts') . "&updateproduct&id_product=" . (int) $row['id_product'] . "' target='new'>E</a>"; $output .= " <a href='#' onclick='InsertRow(this);return(false);'>I</a></td>"; $output .= "</tr>"; } die($output); }
public function sendCampaign() { // get abandoned cart : $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'"; $currency = Context::getContext()->currency->sign; $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $abandoned_carts = Db::getInstance()->ExecuteS($sql); // get all available campaigns $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1'; $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns); // loop on all abandoned carts foreach ($abandoned_carts as $abncart) { // loop on all available campaigns foreach ($allCampaigns as $camp) { $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']); if ($cartIsOnCampaign) { $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $customer = new Customer($abncart['id_customer']); $cR = new CartRule($camp['id_voucher'], $id_lang); $cart = new Cart($abncart['id_cart']); $products = $cart->getProducts(); $campM = new Campaign($camp['id_campaign']); if (!empty($products)) { $cart_content = $campM->getCartContentHeader(); } else { $cart_content = ''; } foreach ($products as $prod) { $p = new Product($prod['id_product'], true, $id_lang); $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false); $total_no_tax = $prod['cart_quantity'] * $price_no_tax; $images = Image::getImages((int) $id_lang, (int) $p->id); $link = new Link(); $cart_content .= '<tr > <td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td> <td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td> <td align="center" >' . Tools::displayprice($price_no_tax) . '</td> <td align="center" >' . $prod['cart_quantity'] . '</td> <td align="center" >' . Tools::displayprice($total_no_tax) . '</td> </tr>'; } $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']); $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/'; // send email to customer : Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id); // Email to admin : Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id); // echo 'ID ' . $abncart['id_cart']; } } } }
protected function formatProduct($id_product, $id_lang) { $link = new Link(); $product = new Product($id_product, true, $id_lang); $category = new Category($product->id_category_default, $id_lang); $product->objectID = $product->id; $product->category = $category->name; $product->url = $link->getProductLink($product->id); /* Cover */ $cover = Image::getCover($product->id); $product->image_link_small = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('small')); $product->image_link_large = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('large')); return $product; }
/** * Returns module content for header * * @param array $params Parameters * @return string Content */ public function hookTop($params) { global $smarty; $languages = Language::getLanguages(); if (!count($languages)) { return; } $link = new Link(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); $phpSelf = isset($_SERVER['PHP_SELF']) ? substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)) : ''; if ($phpSelf == 'product.php' and $id_product = (int) Tools::getValue('id_product')) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } } if ($phpSelf == 'category.php' and $id_category = (int) Tools::getValue('id_category')) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } } if ($phpSelf == 'cms.php' and ($id_cms = (int) Tools::getValue('id_cms') or $id_cms_category = (int) Tools::getValue('id_cms_category'))) { $rewrite_infos = (isset($id_cms) and !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = (isset($id_cms) and !isset($id_cms_category)) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], NULL, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } if (count($default_rewrite)) { $smarty->assign('lang_rewrite_urls', $default_rewrite); } } $smarty->assign('languages', $languages); return $this->display(__FILE__, 'blocklanguages.tpl'); }
public function viewcustomer() { global $currentIndex, $cookie, $link; $irow = 0; $configurations = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_CURRENCY_DEFAULT')); $defaultLanguage = (int) $configurations['PS_LANG_DEFAULT']; $defaultCurrency = (int) $configurations['PS_CURRENCY_DEFAULT']; if (!($customer = $this->loadObject())) { return; } $customerStats = $customer->getStats(); $addresses = $customer->getAddresses($defaultLanguage); $products = $customer->getBoughtProducts(); $discounts = Discount::getCustomerDiscounts($defaultLanguage, (int) $customer->id, false, false); $orders = Order::getCustomerOrders((int) $customer->id, true); $carts = Cart::getCustomerCarts((int) $customer->id); $groups = $customer->getGroups(); $messages = CustomerThread::getCustomerMessages((int) $customer->id); $referrers = Referrer::getReferrers((int) $customer->id); if ($totalCustomer = Db::getInstance()->getValue('SELECT SUM(total_paid_real) FROM ' . _DB_PREFIX_ . 'orders WHERE id_customer = ' . $customer->id . ' AND valid = 1')) { Db::getInstance()->getValue('SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM ' . _DB_PREFIX_ . 'orders WHERE valid = 1 GROUP BY id_customer HAVING SUM(total_paid_real) > ' . $totalCustomer); $countBetterCustomers = (int) Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1; } else { $countBetterCustomers = '-'; } echo ' <fieldset style="width:400px;float: left"><div style="float: right"><a href="' . $currentIndex . '&addcustomer&id_customer=' . $customer->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a></div> <span style="font-weight: bold; font-size: 14px;">' . $customer->firstname . ' ' . $customer->lastname . '</span> <img src="../img/admin/' . ($customer->id_gender == 2 ? 'female' : ($customer->id_gender == 1 ? 'male' : 'unknown')) . '.gif" style="margin-bottom: 5px" /><br /> <a href="mailto:' . $customer->email . '" style="text-decoration: underline; color: blue">' . $customer->email . '</a><br /><br /> ' . $this->l('ID:') . ' ' . sprintf('%06d', $customer->id) . '<br /> ' . $this->l('Registration date:') . ' ' . Tools::displayDate($customer->date_add, (int) $cookie->id_lang, true) . '<br /> ' . $this->l('Last visit:') . ' ' . ($customerStats['last_visit'] ? Tools::displayDate($customerStats['last_visit'], (int) $cookie->id_lang, true) : $this->l('never')) . '<br /> ' . ($countBetterCustomers != '-' ? $this->l('Rank: #') . ' ' . (int) $countBetterCustomers . '<br />' : '') . ' </fieldset> <fieldset style="width:300px;float:left;margin-left:50px"> <div style="float: right"> <a href="' . $currentIndex . '&addcustomer&id_customer=' . $customer->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a> </div> ' . $this->l('Newsletter:') . ' ' . ($customer->newsletter ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . '<br /> ' . $this->l('Opt-in:') . ' ' . ($customer->optin ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . '<br /> ' . $this->l('Age:') . ' ' . $customerStats['age'] . ' ' . (!empty($customer->birthday['age']) ? '(' . Tools::displayDate($customer->birthday, (int) $cookie->id_lang) . ')' : $this->l('unknown')) . '<br /><br /> ' . $this->l('Last update:') . ' ' . Tools::displayDate($customer->date_upd, (int) $cookie->id_lang, true) . '<br /> ' . $this->l('Status:') . ' ' . ($customer->active ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />'); if ($customer->isGuest()) { echo ' <div> ' . $this->l('This customer is registered as') . ' <b>' . $this->l('guest') . '</b>'; if (!Customer::customerExists($customer->email)) { echo ' <form method="POST" action="index.php?tab=AdminCustomers&id_customer=' . (int) $customer->id . '&token=' . Tools::getAdminTokenLite('AdminCustomers') . '"> <input type="hidden" name="id_lang" value="' . (int) (sizeof($orders) ? $orders[0]['id_lang'] : Configuration::get('PS_LANG_DEFAULT')) . '" /> <p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="' . $this->l('Transform to customer') . '" /></p> ' . $this->l('This feature generates a random password and sends an e-mail to the customer </form>'); } else { echo '</div><div><b style="color:red;">' . $this->l('A registered customer account exists with the same email address') . '</b>'; } echo ' </div> '; } echo ' </fieldset> <div class="clear"> </div>'; echo '<fieldset style="height:190px"><legend><img src="../img/admin/cms.gif" /> ' . $this->l('Add a private note') . '</legend> <p>' . $this->l('This note will be displayed to all the employees but not to the customer.') . '</p> <form action="ajax.php" method="post" onsubmit="saveCustomerNote();return false;" id="customer_note"> <textarea name="note" id="noteContent" style="width:600px;height:100px" onkeydown="$(\'#submitCustomerNote\').removeAttr(\'disabled\');">' . Tools::htmlentitiesUTF8($customer->note) . '</textarea><br /> <input type="submit" id="submitCustomerNote" class="button" value="' . $this->l(' Save ') . '" style="float:left;margin-top:5px" disabled="disabled" /> <span id="note_feedback" style="float:left;margin:10px 0 0 10px"></span> </form> </fieldset> <div class="clear"> </div> <script type="text/javascript"> function saveCustomerNote() { $("#note_feedback").html("<img src=\\"../img/loader.gif\\" />").show(); var noteContent = $("#noteContent").val(); $.post("ajax.php", {submitCustomerNote:1,id_customer:' . (int) $customer->id . ',note:noteContent}, function (r) { $("#note_feedback").html("").hide(); if (r == "ok") { $("#note_feedback").html("<b style=\\"color:green\\">' . addslashes($this->l('Your note has been saved')) . '</b>").fadeIn(400); $("#submitCustomerNote").attr("disabled", "disabled"); } else if (r == "error:validation") $("#note_feedback").html("<b style=\\"color:red\\">' . addslashes($this->l('Error: your note is not valid')) . '</b>").fadeIn(400); else if (r == "error:update") $("#note_feedback").html("<b style=\\"color:red\\">' . addslashes($this->l('Error: cannot save your note')) . '</b>").fadeIn(400); $("#note_feedback").fadeOut(3000); }); } </script>'; echo '<h2>' . $this->l('Messages') . ' (' . sizeof($messages) . ')</h2>'; if (sizeof($messages)) { echo ' <table cellspacing="0" cellpadding="0" class="table"> <tr> <th class="center">' . $this->l('Status') . '</th> <th class="center">' . $this->l('Message') . '</th> <th class="center">' . $this->l('Sent on') . '</th> </tr>'; foreach ($messages as $message) { echo '<tr> <td>' . $message['status'] . '</td> <td><a href="index.php?tab=AdminCustomerThreads&id_customer_thread=' . (int) $message['id_customer_thread'] . '&viewcustomer_thread&token=' . Tools::getAdminTokenLite('AdminCustomerThreads') . '">' . substr(strip_tags(html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8')), 0, 75) . '...</a></td> <td>' . Tools::displayDate($message['date_add'], (int) $cookie->id_lang, true) . '</td> </tr>'; } echo '</table> <div class="clear"> </div>'; } else { echo $customer->firstname . ' ' . $customer->lastname . ' ' . $this->l('has never contacted you.'); } // display hook specified to this page : AdminCustomers if (($hook = Module::hookExec('adminCustomers', array('id_customer' => $customer->id))) !== false) { echo '<div>' . $hook . '</div>'; } echo '<div class="clear"> </div>'; echo '<h2>' . $this->l('Groups') . ' (' . sizeof($groups) . ')</h2>'; if ($groups and sizeof($groups)) { echo ' <table cellspacing="0" cellpadding="0" class="table"> <tr> <th class="center">' . $this->l('ID') . '</th> <th class="center">' . $this->l('Name') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; $tokenGroups = Tools::getAdminToken('AdminGroups' . (int) Tab::getIdFromClassName('AdminGroups') . (int) $cookie->id_employee); foreach ($groups as $group) { $objGroup = new Group($group); echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminGroups&id_group=' . $objGroup->id . '&viewgroup&token=' . $tokenGroups . '\'"> <td class="center">' . $objGroup->id . '</td> <td>' . $objGroup->name[$defaultLanguage] . '</td> <td align="center"><a href="?tab=AdminGroups&id_group=' . $objGroup->id . '&viewgroup&token=' . $tokenGroups . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo ' </table>'; } echo '<div class="clear"> </div>'; echo '<h2>' . $this->l('Orders') . ' (' . sizeof($orders) . ')</h2>'; if ($orders and sizeof($orders)) { $totalOK = 0; $ordersOK = array(); $ordersKO = array(); $tokenOrders = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee); foreach ($orders as $order) { if ($order['valid']) { $ordersOK[] = $order; $totalOK += $order['total_paid_real']; } else { $ordersKO[] = $order; } } $orderHead = ' <table cellspacing="0" cellpadding="0" class="table float"> <tr> <th class="center">' . $this->l('ID') . '</th> <th class="center">' . $this->l('Date') . '</th> <th class="center">' . $this->l('Products') . '</th> <th class="center">' . $this->l('Total paid') . '</th> <th class="center">' . $this->l('Payment') . '</th> <th class="center">' . $this->l('State') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; $orderFoot = '</table>'; if ($countOK = sizeof($ordersOK)) { echo '<div style="float:left;margin-right:20px"><h3 style="color:green;font-weight:700">' . $this->l('Valid orders:') . ' ' . $countOK . ' ' . $this->l('for') . ' ' . Tools::displayPrice($totalOK, new Currency($defaultCurrency)) . '</h3>' . $orderHead; foreach ($ordersOK as $order) { echo '<tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . $tokenOrders . '\'"> <td class="center">' . $order['id_order'] . '</td> <td>' . Tools::displayDate($order['date_add'], (int) $cookie->id_lang) . '</td> <td align="right">' . $order['nb_products'] . '</td> <td align="right">' . Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency'])) . '</td> <td>' . $order['payment'] . '</td> <td>' . $order['order_state'] . '</td> <td align="center"><a href="?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . $tokenOrders . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo $orderFoot . '</div>'; } if ($countKO = sizeof($ordersKO)) { echo '<div style="float:left;margin-right:20px"><h3 style="color:red;font-weight:700">' . $this->l('Invalid orders:') . ' ' . $countKO . '</h3>' . $orderHead; foreach ($ordersKO as $order) { echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . $tokenOrders . '\'"> <td class="center">' . $order['id_order'] . '</td> <td>' . Tools::displayDate($order['date_add'], (int) $cookie->id_lang) . '</td> <td align="right">' . $order['nb_products'] . '</td> <td align="right">' . Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency'])) . '</td> <td>' . $order['payment'] . '</td> <td>' . $order['order_state'] . '</td> <td align="center"><a href="?tab=AdminOrders&id_order=' . $order['id_order'] . '&vieworder&token=' . $tokenOrders . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo $orderFoot . '</div><div class="clear"> </div>'; } } else { echo $customer->firstname . ' ' . $customer->lastname . ' ' . $this->l('has not placed any orders yet'); } if ($products and sizeof($products)) { echo '<div class="clear"> </div> <h2>' . $this->l('Products') . ' (' . sizeof($products) . ')</h2> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th class="center">' . $this->l('Date') . '</th> <th class="center">' . $this->l('Name') . '</th> <th class="center">' . $this->l('Quantity') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; $tokenOrders = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee); foreach ($products as $product) { echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order=' . $product['id_order'] . '&vieworder&token=' . $tokenOrders . '\'"> <td>' . Tools::displayDate($product['date_add'], (int) $cookie->id_lang, true) . '</td> <td>' . $product['product_name'] . '</td> <td align="right">' . $product['product_quantity'] . '</td> <td align="center"><a href="?tab=AdminOrders&id_order=' . $product['id_order'] . '&vieworder&token=' . $tokenOrders . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo ' </table>'; } echo '<div class="clear"> </div> <h2>' . $this->l('Addresses') . ' (' . sizeof($addresses) . ')</h2>'; if (sizeof($addresses)) { echo ' <table cellspacing="0" cellpadding="0" class="table"> <tr> <th>' . $this->l('Company') . '</th> <th>' . $this->l('Name') . '</th> <th>' . $this->l('Address') . '</th> <th>' . $this->l('Country') . '</th> <th>' . $this->l('Phone number(s)') . '</th> <th>' . $this->l('Actions') . '</th> </tr>'; $tokenAddresses = Tools::getAdminToken('AdminAddresses' . (int) Tab::getIdFromClassName('AdminAddresses') . (int) $cookie->id_employee); foreach ($addresses as $address) { echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . '> <td>' . ($address['company'] ? $address['company'] : '--') . '</td> <td>' . $address['firstname'] . ' ' . $address['lastname'] . '</td> <td>' . $address['address1'] . ($address['address2'] ? ' ' . $address['address2'] : '') . ' ' . $address['postcode'] . ' ' . $address['city'] . '</td> <td>' . $address['country'] . '</td> <td>' . ($address['phone'] ? $address['phone'] . ($address['phone_mobile'] ? '<br />' . $address['phone_mobile'] : '') : ($address['phone_mobile'] ? '<br />' . $address['phone_mobile'] : '--')) . '</td> <td align="center"> <a href="?tab=AdminAddresses&id_address=' . $address['id_address'] . '&addaddress&token=' . $tokenAddresses . '"><img src="../img/admin/edit.gif" /></a> <a href="?tab=AdminAddresses&id_address=' . $address['id_address'] . '&deleteaddress&token=' . $tokenAddresses . '"><img src="../img/admin/delete.gif" /></a> </td> </tr>'; } echo ' </table>'; } else { echo $customer->firstname . ' ' . $customer->lastname . ' ' . $this->l('has not registered any addresses yet') . '.'; } echo '<div class="clear"> </div> <h2>' . $this->l('Discounts') . ' (' . sizeof($discounts) . ')</h2>'; if (sizeof($discounts)) { echo ' <table cellspacing="0" cellpadding="0" class="table"> <tr> <th>' . $this->l('ID') . '</th> <th>' . $this->l('Code') . '</th> <th>' . $this->l('Type') . '</th> <th>' . $this->l('Value') . '</th> <th>' . $this->l('Qty available') . '</th> <th>' . $this->l('Status') . '</th> <th>' . $this->l('Actions') . '</th> </tr>'; $tokenDiscounts = Tools::getAdminToken('AdminDiscounts' . (int) Tab::getIdFromClassName('AdminDiscounts') . (int) $cookie->id_employee); foreach ($discounts as $discount) { echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . '> <td align="center">' . $discount['id_discount'] . '</td> <td>' . $discount['name'] . '</td> <td>' . $discount['type'] . '</td> <td align="right">' . $discount['value'] . '</td> <td align="center">' . $discount['quantity_for_user'] . '</td> <td align="center"><img src="../img/admin/' . ($discount['active'] ? 'enabled.gif' : 'disabled.gif') . '" alt="' . $this->l('Status') . '" title="' . $this->l('Status') . '" /></td> <td align="center"> <a href="?tab=AdminDiscounts&id_discount=' . $discount['id_discount'] . '&adddiscount&token=' . $tokenDiscounts . '"><img src="../img/admin/edit.gif" /></a> <a href="?tab=AdminDiscounts&id_discount=' . $discount['id_discount'] . '&deletediscount&token=' . $tokenDiscounts . '"><img src="../img/admin/delete.gif" /></a> </td> </tr>'; } echo ' </table>'; } else { echo $customer->firstname . ' ' . $customer->lastname . ' ' . $this->l('has no discount vouchers') . '.'; } echo '<div class="clear"> </div>'; echo '<div style="float:left"> <h2>' . $this->l('Carts') . ' (' . sizeof($carts) . ')</h2>'; if ($carts and sizeof($carts)) { echo ' <table cellspacing="0" cellpadding="0" class="table"> <tr> <th class="center">' . $this->l('ID') . '</th> <th class="center">' . $this->l('Date') . '</th> <th class="center">' . $this->l('Total') . '</th> <th class="center">' . $this->l('Carrier') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; $tokenCarts = Tools::getAdminToken('AdminCarts' . (int) Tab::getIdFromClassName('AdminCarts') . (int) $cookie->id_employee); foreach ($carts as $cart) { $cartI = new Cart((int) $cart['id_cart']); $summary = $cartI->getSummaryDetails(); $currency = new Currency((int) $cart['id_currency']); $carrier = new Carrier((int) $cart['id_carrier']); echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'?tab=AdminCarts&id_cart=' . $cart['id_cart'] . '&viewcart&token=' . $tokenCarts . '\'"> <td class="center">' . sprintf('%06d', $cart['id_cart']) . '</td> <td>' . Tools::displayDate($cart['date_add'], (int) $cookie->id_lang, true) . '</td> <td align="right">' . Tools::displayPrice($summary['total_price'], $currency) . '</td> <td>' . $carrier->name . '</td> <td align="center"><a href="index.php?tab=AdminCarts&id_cart=' . $cart['id_cart'] . '&viewcart&token=' . $tokenCarts . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo ' </table>'; } else { echo $this->l('No cart available') . '.'; } echo '</div>'; $interested = Db::getInstance()->ExecuteS('SELECT DISTINCT id_product FROM ' . _DB_PREFIX_ . 'cart_product cp INNER JOIN ' . _DB_PREFIX_ . 'cart c on c.id_cart = cp.id_cart WHERE c.id_customer = ' . (int) $customer->id . ' AND cp.id_product NOT IN ( SELECT product_id FROM ' . _DB_PREFIX_ . 'orders o inner join ' . _DB_PREFIX_ . 'order_detail od ON o.id_order = od.id_order WHERE o.valid = 1 AND o.id_customer = ' . (int) $customer->id . ')'); if (count($interested)) { echo '<div style="float:left;margin-left:20px"> <h2>' . $this->l('Products') . ' (' . count($interested) . ')</h2> <table cellspacing="0" cellpadding="0" class="table">'; foreach ($interested as $p) { $product = new Product((int) $p['id_product'], false, $cookie->id_lang); echo ' <tr ' . ($irow++ % 2 ? 'class="alt_row"' : '') . ' style="cursor: pointer" onclick="document.location = \'' . $link->getProductLink((int) $product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, (int) $cookie->id_lang)) . '\'"> <td>' . (int) $product->id . '</td> <td>' . Tools::htmlentitiesUTF8($product->name) . '</td> <td align="center"><a href="' . $link->getProductLink((int) $product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, (int) $cookie->id_lang)) . '"><img src="../img/admin/details.gif" /></a></td> </tr>'; } echo '</table></div>'; } echo '<div class="clear"> </div>'; /* Last connections */ $connections = $customer->getLastConnections(); if (sizeof($connections)) { echo '<h2>' . $this->l('Last connections') . '</h2> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th style="width: 200px">' . $this->l('Date') . '</th> <th style="width: 100px">' . $this->l('Pages viewed') . '</th> <th style="width: 100px">' . $this->l('Total time') . '</th> <th style="width: 100px">' . $this->l('Origin') . '</th> <th style="width: 100px">' . $this->l('IP Address') . '</th> </tr>'; foreach ($connections as $connection) { echo '<tr> <td>' . Tools::displayDate($connection['date_add'], (int) $cookie->id_lang, true) . '</td> <td>' . (int) $connection['pages'] . '</td> <td>' . $connection['time'] . '</td> <td>' . ($connection['http_referer'] ? preg_replace('/^www./', '', parse_url($connection['http_referer'], PHP_URL_HOST)) : $this->l('Direct link')) . '</td> <td>' . $connection['ipaddress'] . '</td> </tr>'; } echo '</table><div class="clear"> </div>'; } if (sizeof($referrers)) { echo '<h2>' . $this->l('Referrers') . '</h2> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th style="width: 200px">' . $this->l('Date') . '</th> <th style="width: 200px">' . $this->l('Name') . '</th> </tr>'; foreach ($referrers as $referrer) { echo '<tr> <td>' . Tools::displayDate($referrer['date_add'], (int) $cookie->id_lang, true) . '</td> <td>' . $referrer['name'] . '</td> </tr>'; } echo '</table><div class="clear"> </div>'; } echo '<a href="' . $currentIndex . '&token=' . $this->token . '"><img src="../img/admin/arrow2.gif" /> ' . $this->l('Back to customer list') . '</a><br />'; global $smarty; $smarty->assign('balance_points', VBRewards::getCustomerPoints($customer->id)); $smarty->assign('redeemed_points', VBRewards::getCustomerPointsRedeemed($customer->id)); $referrals = Customer::getCustomerReferrals($customer->id); if ($referrals) { $smarty->assign('total_referred', count($referrals)); } else { $smarty->assign('total_referred', 0); } $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $res = $db->ExecuteS("SELECT\n description,\n reference,\n date_add,\n points_awarded,\n coalesce(points_deducted, '-') as `points_deducted`,\n balance FROM vb_customer_rewards WHERE id_customer = " . $customer->id . "\n order by id_reward desc"); $smarty->assign('vbpoints', $res); $smarty->display(_PS_THEME_DIR_ . 'admin/customer_points.tpl'); //Customer's wishlist $wishlist_items = $db->ExecuteS("select \n ps.name,\n w.id_product, \n p.reference,\n w.date_add \n from \n ps_wishlist w \n join ps_product_lang ps \n on ps.id_product = w.id_product\n join ps_product p\n on p.id_product = w.id_product\n where w.id_customer = {$customer->id} and ps.id_lang=1\n order by w.date_add desc"); $link = new Link(); foreach ($wishlist_items as &$item) { $item["link"] = $link->getProductLink($item["id_product"]); } $smarty->assign('wishlist_items', $wishlist_items); $smarty->display(_PS_THEME_DIR_ . 'admin/customer_wishlist.tpl'); }
private function getProductLink($product_id, $link_rewrite = null) { global $link; if (isset($link) && method_exists($link, 'getProductLink')) { return $link->getProductLink((int) $product_id); } else { $link = new Link(); return $link->getProductLink((int) $product_id); } }
public function generateFlux() { if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) { die('Invalid Token'); } $titles = array(0 => 'id_produit', 1 => 'nom_produit', 2 => 'url_produit', 3 => 'url_image', 4 => 'description', 5 => 'description_courte', 6 => 'prix', 7 => 'prix_barre', 8 => 'frais_de_port', 9 => 'delaiLiv', 10 => 'marque', 11 => 'rayon', 12 => 'stock', 13 => 'qte_stock', 14 => 'EAN', 15 => 'poids', 16 => 'ecotaxe', 17 => 'TVA', 18 => 'Reference constructeur', 19 => 'Reference fournisseur'); echo implode("|", $titles) . "\r\n"; //For Shipping $configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); $products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT']); $defaultCountry = new Country($configuration['PS_COUNTRY_DEFAULT'], Configuration::get('PS_LANG_DEFAULT')); $id_zone = (int) $defaultCountry->id_zone; $carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']); $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']}); foreach ($products as $key => $produit) { $product = new Product((int) $produit['id_product'], true, $configuration['PS_LANG_DEFAULT']); //For links $link = new Link(); //For images $cover = $product->getCover($product->id); $ids = $product->id . '-' . $cover['id_image']; //For shipping if ($product->getPrice(true, NULL, 2, NULL, false, true, 1) >= (double) $configuration['PS_SHIPPING_FREE_PRICE'] and (double) $configuration['PS_SHIPPING_FREE_PRICE'] > 0) { $shipping = 0; } elseif (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $product->weight >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) { $shipping = 0; } else { if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) { $shipping = (double) $configuration['PS_SHIPPING_HANDLING']; } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone); } else { $shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, NULL, 2, NULL, false, true, 1), $id_zone); } $shipping *= 1 + $carrierTax / 100; $shipping = (double) Tools::ps_round((double) $shipping, 2); } $data = array(); $data[0] = $product->id; $data[1] = $product->name; $data[2] = $link->getProductLink($product); $data[3] = $link->getImageLink($product->link_rewrite, $ids, 'large'); $data[4] = $product->description; $data[5] = $product->description_short; $data[6] = $product->getPrice(true, NULL, 2, NULL, false, true, 1); $data[7] = $product->getPrice(true, NULL, 2, NULL, false, false, 1); $data[8] = $shipping; $data[9] = $carrier->delay[2]; $data[10] = $product->manufacturer_name; $data[11] = $product->category; $data[12] = $product->quantity > 0 ? 'oui' : 'non'; $data[13] = $product->quantity; $data[14] = $product->ean13; $data[15] = $product->weight; $data[16] = $product->ecotax; $data[17] = $product->tax_rate; $data[18] = $product->reference; $data[19] = $product->supplier_reference; foreach ($data as $key => $value) { $data[$key] = $this->clean($value); } echo implode("|", $data) . "\r\n"; } }
/** * Hydrate $link_sitemap with products link * * @param array $link_sitemap contain all the links for the Google Sitemap file to be generated * @param string $lang language of link to add * @param int $index index of the current Google Sitemap file * @param int $i count of elements added to sitemap main array * @param int $id_product product object identifier * * @return bool */ private function _getProductLink(&$link_sitemap, $lang, &$index, &$i, $id_product = 0) { $link = new Link(); if (method_exists('ShopUrl', 'resetMainDomainCache')) { ShopUrl::resetMainDomainCache(); } $products_id = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product_shop` WHERE `active` = 1 AND `id_shop`=' . $this->context->shop->id); foreach ($products_id as $product_id) { $product = new Product((int) $product_id['id_product'], false, (int) $lang['id_lang']); if (_PS_VERSION_ >= 1.5) { $url = $link->getProductLink($product, $product->link_rewrite, htmlspecialchars(strip_tags($product->category)), $product->ean13, (int) $lang['id_lang'], (int) $this->context->shop->id, 0, true); } else { $category = new Category((int) $product->id_category_default, (int) $lang['id_lang']); $url = $link->getProductLink($product, Configuration::get('PS_REWRITING_SETTINGS') ? $product->link_rewrite : false, htmlspecialchars(strip_tags($category->name)), $product->ean13, (int) $lang['id_lang']); } $id_image = Product::getCover((int) $product_id['id_product']); if (isset($id_image['id_image'])) { $image_link = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . (int) $id_image['id_image']); $image_link = !in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link)) ? str_replace(array('https', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri), array('http', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri . Context::getContext()->shop->virtual_uri), $image_link) : $image_link; } $file_headers = Configuration::get('GSITEMAP_CHECK_IMAGE_FILE') ? @get_headers($image_link) : true; $image_product = array(); if (isset($image_link) && ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true)) { $image_product = array('title_img' => htmlspecialchars(strip_tags($product->name)), 'caption' => htmlspecialchars(strip_tags($product->description_short)), 'link' => $image_link); } if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'product', 'page' => 'product', 'lastmod' => $product->date_upd, 'link' => $url, 'image' => $image_product), $lang['iso_code'], $index, $i, $product_id['id_product'])) { return false; } unset($image_link); } return true; }
public static function getUrlsProduct($product_id) { $product_exist = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'product WHERE id_product =' . (int) $product_id); if ($product_exist) { $o_product = new Product($product_id, false, (int) Configuration::get('PS_LANG_DEFAULT')); $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://'; $use_ssl = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false; $protocol_content = $use_ssl ? 'https://' : 'http://'; $link = new Link($protocol_link, $protocol_content); $id_cover_image = Image::getCover($product_id); $image_path = $link->getImageLink($o_product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')], $id_cover_image['id_image']); $url_product = $link->getProductLink($product_id); return array('url_product' => $url_product, 'url_image_product' => $image_path); } }
public static function getProductProperties($id_lang, $row) { if (!$row['id_product']) { return false; } // Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries $row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']); if ((!isset($row['id_product_attribute']) or !$row['id_product_attribute']) and (isset($row['cache_default_attribute']) and ($ipa_default = $row['cache_default_attribute']) !== NULL or $ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp']))) { $row['id_product_attribute'] = $ipa_default; } if (!isset($row['id_product_attribute'])) { $row['id_product_attribute'] = 0; } // Tax $usetax = Tax::excludeTaxeOption(); $cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) $usetax; if (array_key_exists($cacheKey, self::$producPropertiesCache)) { return self::$producPropertiesCache[$cacheKey]; } // Datas $link = new Link(); $row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang); $row['link'] = $link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']); $row['attribute_price'] = (isset($row['id_product_attribute']) and $row['id_product_attribute']) ? (double) Product::getProductAttributePrice($row['id_product_attribute']) : 0; $row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6); if (self::$_taxCalculationMethod == PS_TAX_EXC) { $row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2); $row['price'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6); $row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2, NULL, false, false); } else { $row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2), 2); $row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6, NULL, false, false); } $row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, (int) $row['id_product_attribute'], 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices); $row['specific_prices'] = $specific_prices; if ($row['id_product_attribute']) { $row['quantity_all_versions'] = $row['quantity']; $row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL); } $row['id_image'] = Product::defineProductImage($row, $id_lang); $row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']); $row['attachments'] = (!isset($row['cache_has_attachments']) or $row['cache_has_attachments']) ? Product::getAttachmentsStatic((int) $id_lang, $row['id_product']) : array(); // Pack management $row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack']; $row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array(); $row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0; if ($row['pack'] and !Pack::isInStock($row['id_product'])) { $row['quantity'] = 0; } self::$producPropertiesCache[$cacheKey] = $row; return self::$producPropertiesCache[$cacheKey]; }
function displayFormInformations($obj, $currency, $languages, $defaultLanguage) { global $currentIndex, $cookie; $iso = Language::getIsoById(intval($cookie->id_lang)); $divLangName = 'cname¤cdesc¤cdesc_short¤clink_rewrite¤cmeta_description¤cmeta_title¤cmeta_keywords¤ctags¤cavailable_now¤cavailable_later'; $qty_state = 'readonly'; $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product')); if ($qty === false) { if (Validate::isLoadedObject($obj)) { $qty = $this->getFieldValue($obj, 'quantity'); } else { $qty = 1; } $qty_state = ''; } $cover = Product::getCover($obj->id); $link = new Link(); //includeDatepicker(array('reduction_from', 'reduction_to')); echo ' <div class="tab-page" id="step1"> <h4 class="tab">1. ' . $this->l('Info.') . '</h4> <b>' . $this->l('Product global informations') . '</b> - '; if (isset($obj->id)) { echo ' <a href="' . $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $defaultLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), intval($cookie->id_lang))) . '"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>'; if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) { echo ' - <a href="index.php?tab=AdminStatsModules&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStatsModules' . intval(Tab::getIdFromClassName('AdminStatsModules')) . intval($cookie->id_employee)) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>'; } } echo ' <hr class="clear"/> <br /> <table cellpadding="5" style="width:100%"> <tr> <td class="col-left">' . $this->l('Name:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '" value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' onchange="updateCurrentText();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cname'); echo '<script type="text/javascript">updateCurrentText();</script> </td> </tr> <tr> <td style="vertical-align:top">' . $this->l('Status:') . '</td> <td style="padding-bottom:5px;"> <input style="float:left;" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label> <br style="clear:both;" /> <input style="float:left;" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . '</label> </td> </tr> <tr> <td>' . $this->l('Manufacturer:') . '</td> <td style="padding-bottom:5px;"> <select name="id_manufacturer" id="id_manufacturer"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) { echo ' <option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . intval(Tab::getIdFromClassName('AdminManufacturers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> <script type="text/javascript"> var ajaxManufacturersClicked = false; $("select#id_manufacturer").focus( function() { if (ajaxManufacturersClicked == true) return; else ajaxManufacturersClicked = true; $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductManufacturers:1}, function(j) { var options = \'\'; for (var i = 0; i < getE("id_manufacturer").options.length; i++) { if (getE("id_manufacturer").options[i].innerHTML == \'----------\') options += \'<option disabled="disabled">----------</option>\'; else options += \'<option value="\' + getE("id_manufacturer").options[i].value + \'">\' + getE("id_manufacturer").options[i].innerHTML + \'</option>\'; } for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_manufacturer").html(options); } ) } ); </script> </td> </tr> <tr> <td>' . $this->l('Supplier:') . '</td> <td style="padding-bottom:5px;"> <select name="id_supplier" id="id_supplier"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) { echo ' <option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . intval(Tab::getIdFromClassName('AdminSuppliers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> <script type="text/javascript"> var ajaxSuppliersClicked = false; $("select#id_supplier").focus( function() { if (ajaxSuppliersClicked == true) return; else ajaxSuppliersClicked = true; $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductSuppliers:1}, function(j) { var options = \'\'; for (var i = 0; i < getE("id_supplier").options.length; i++) { if (getE("id_supplier").options[i].innerHTML == \'----------\') options += \'<option disabled="disabled">----------</option>\'; else options += \'<option value="\' + getE("id_supplier").options[i].value + \'">\' + getE("id_supplier").options[i].innerHTML + \'</option>\'; } for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_supplier").html(options); } ) } ); </script> </td> </tr> <tr> <td class="col-left">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" name="ean13" value="' . $this->getFieldValue($obj, 'ean13') . '" style="width: 110px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td class="col-left">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" name="location" value="' . $this->getFieldValue($obj, 'location') . '" style="width: 101px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td class="col-left">' . $this->l('Weight:') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . ' </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr>'; $this->displayPack($obj); echo ' <tr><td colspan="2"><hr style="width:730px;"></td></tr>'; /* * Form for add a virtual product like software, mp3, etc... */ $productDownload = new ProductDownload(); if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) { $productDownload = new ProductDownload($id_product_download); } ?> <script type="text/javascript"> // <![CDATA[ ThickboxI18nImage = '<?php echo $this->l('Image'); ?> '; ThickboxI18nOf = '<?php echo $this->l('of'); ?> ';; ThickboxI18nClose = '<?php echo $this->l('Close'); ?> '; ThickboxI18nOrEscKey = '<?php echo $this->l('(or "Esc")'); ?> '; ThickboxI18nNext = '<?php echo $this->l('Next >'); ?> '; ThickboxI18nPrev = '<?php echo $this->l('< Previous'); ?> '; tb_pathToImage = '../img/loadingAnimation.gif'; //]]> </script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/thickbox-modified.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/ajaxfileupload.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> date.js"></script> <style type="text/css"> <!-- @import url(<?php echo _PS_CSS_DIR_; ?> thickbox.css); --> </style> <script type="text/javascript"> <!-- function toggleVirtualProduct(elt) { if (elt.checked) { $('#virtual_good').show('slow'); getE('out_of_stock_1').checked = 'checked'; getE('out_of_stock_2').readOnly = true; getE('out_of_stock_3').readOnly = true; getE('label_out_of_stock_2').setAttribute('for', ''); getE('label_out_of_stock_3').setAttribute('for', ''); } else { $('#virtual_good').hide('slow'); getE('out_of_stock_2').readOnly = false; getE('out_of_stock_3').readOnly = false; getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2'); getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3'); } } function uploadFile() { $.ajaxFileUpload ( { url:'./uploadProductFile.php', secureuri:false, fileElementId:'virtual_product_file', dataType: 'xml', success: function (data, status) { data = data.getElementsByTagName('return')[0]; var result = data.getAttribute("result"); var msg = data.getAttribute("msg"); var fileName = data.getAttribute("filename"); if(result == "error") { $("#upload-confirmation").html('<p>error: ' + msg + '</p>'); } else { $('#virtual_product_file').remove(); $('#virtual_product_file_label').hide(); $('#virtual_product_name').attr('value', fileName); $('#upload-confirmation').html( '<a class="link" href="get-file-admin.php?file=' + msg + '"><?php echo $this->l('The file'); ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded'); ?> </a>' + '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />'); } } } ); } --> </script> <?php echo ' <script type="text/javascript"> var newLabel = \'' . $this->l('New label') . '\'; var choose_language = \'' . $this->l('Choose language:') . '\'; var required = \'' . $this->l('required') . '\'; var customizationUploadableFileNumber = ' . intval($this->getFieldValue($obj, 'uploadable_files')) . '; var customizationTextFieldNumber = ' . intval($this->getFieldValue($obj, 'text_fields')) . '; var uploadableFileLabel = 0; var textFieldLabel = 0; var defaultLanguage = ' . intval($defaultLanguage) . '; var languages = new Array();'; $i = 0; foreach ($languages as $language) { echo 'languages[' . $i++ . '] = new Array(' . intval($language['id_lang']) . ', \'' . $language['iso_code'] . '\', \'' . htmlentities($language['name'], ENT_COMPAT, 'UTF-8') . '\');' . "\n"; } echo ' </script>'; ?> <tr> <td colspan="2"> <input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onchange="toggleVirtualProduct(this)" onclick="toggleVirtualProduct(this);" <?php if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) { echo 'checked="checked"'; } ?> /> <label for="is_virtual_good" class="t bold"><?php echo $this->l('Is this a downloadable product?'); ?> </label> <div id="virtual_good" <?php if (!$productDownload->id or !$productDownload->active) { echo 'style="display:none;"'; } ?> > <?php if (!ProductDownload::checkWritableDir()) { ?> <p class="alert"> <?php echo $this->l('Your download repository is not writable.'); ?> <br/> <?php echo realpath(_PS_DOWNLOAD_DIR_); ?> </p> <?php } else { ?> <?php if ($productDownload->id) { echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />'; } ?> <p class="block"> <?php if (!$productDownload->checkFile()) { ?> <?php if ($productDownload->id) { ?> <p class="alert"> <?php echo $this->l('This product is missing'); ?> :<br/> <?php echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename; ?> </p> <?php } ?> <p><?php echo $this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize'); ?> </p> <?php if (!strval(Tools::getValue('virtual_product_filename'))) { ?> <label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php echo $this->l('Upload a file'); ?> </label> <input type="file" id="virtual_product_file" name="virtual_product_file" value="" class="" onchange="uploadFile()" maxlength="<?php echo $this->maxFileSize; ?> " /> <?php } ?> <div id="upload-confirmation"> <?php if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $up_filename; ?> " /> <?php } ?> </div> <?php } else { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $productDownload->physically_filename; ?> " /> <?php echo $this->l('This is the link') . ': ' . $productDownload->getHtmlLink(false, true); ?> <a href="confirm.php?height=200&width=300&modal=true&referer=<?php echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true'); ?> " class="thickbox red" title="<?php echo $this->l('Delete this file'); ?> "><?php echo $this->l('Delete this file'); ?> </a> <?php } // check if file exists ?> </p> <p class="block"> <label for="virtual_product_name" class="t"><?php echo $this->l('Filename'); ?> </label> <input type="text" id="virtual_product_name" name="virtual_product_name" class="" value="<?php echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8'); ?> " /> <span class="hint" name="help_box" style="display:none;"><?php echo $this->l('The complete filename with its extension (e.g., Our best song.mp3)'); ?> </span> </p> <p class="block"> <label for="virtual_product_nb_downloable" class="t"><?php echo $this->l('Number of downloads'); ?> </label> <input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="6" /> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('Number of authorized downloads per customer'); ?> </span> </p> <p class="block"> <label for="virtual_product_expiration_date" class="t"><?php echo $this->l('Expiration date'); ?> </label> <input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8'); ?> " size="11" maxlength="10" autocomplete="off" /> <?php echo $this->l('Format: YYYY-MM-DD'); ?> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('No expiration date if you leave this blank'); ?> </span> </p> <p class="block"> <label for="virtual_product_nb_days" class="t"><?php echo $this->l('Number of days'); ?> </label> <input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="4" /><sup> *</sup> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('How many days this file can be accessed by customers'); ?> </span> </p> <?php } // check if download directory is writable ?> </div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <script type="text/javascript"> if ($('#is_virtual_good').attr('checked')) $('#virtual_good').show('slow'); </script> <?php echo ' <tr> <td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span> </td> </tr>'; echo ' <tr> <td class="col-left">' . $this->l('Pre-tax retail price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . $this->getFieldValue($obj, 'price') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); calcPriceTI();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '<sup> *</sup> <span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span> </td> </tr>'; $taxes = Tax::getTaxes(intval($cookie->id_lang)); echo '<script type="text/javascript">'; echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n"; echo 'taxesArray = new Array ();' . "\n"; echo 'taxesArray[0] = 0', ";\n"; foreach ($taxes as $k => $tax) { echo 'taxesArray[' . $tax['id_tax'] . ']=' . $tax['rate'] . "\n"; } echo ' </script>'; echo ' <tr> <td class="col-left">' . $this->l('Tax:') . '</td> <td style="padding-bottom:5px;"> <select onChange="javascript:calcPriceTI();" name="id_tax" id="id_tax" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '> <option value="0"' . ($this->getFieldValue($obj, 'id_tax') == 0 ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>'; foreach ($taxes as $k => $tax) { echo ' <option value="' . $tax['id_tax'] . '"' . ($this->getFieldValue($obj, 'id_tax') == $tax['id_tax'] ? ' selected="selected"' : '') . '>' . stripslashes($tax['name']) . ' (' . $tax['rate'] . '%)</option>'; } echo ' </select>'; if (Tax::excludeTaxeOption()) { echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . intval(Tab::getIdFromClassName('AdminTaxes')) . intval($cookie->id_employee)) . '">' . $this->l('Tax options') . '</a></b>)'; echo '<input type="hidden" value="' . intval($this->getFieldValue($obj, 'id_tax')) . '" name="id_tax" />'; } echo '</td> </tr> <tr> <td class="col-left">' . $this->l('Retail price with tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onKeyUp="noComma(\'priceTI\'); calcPriceTE();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px"> </td> </tr> <tr> <td class="col-left">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">(' . $this->l('already included in price') . ')</span> </td> </tr> <tr> <td class="col-left">' . $this->l('Reduction amount:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? ' ' . $currency->sign . ' ' : '') . '<input size="11" maxlength="14" type="text" name="reduction_price" id="reduction_price" value="' . $this->getFieldValue($obj, 'reduction_price') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPrice();" /> ' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="padding-right: 15px; padding-left: 15px; font-weight: bold">' . $this->l('OR') . '</span> <input size="10" maxlength="14" type="text" name="reduction_percent" id="reduction_percent" value="' . $this->getFieldValue($obj, 'reduction_percent') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPercent();" /> % </td> </tr> <tr> <td class="col-left"> </td> <td>' . $this->l('available from') . ' <input type="text" id="reduction_from" name="reduction_from" value="' . (($from = $this->getFieldValue($obj, 'reduction_from') and $from != '0000-00-00' and $from != '1942-01-01') ? $from : date('Y-m-d')) . '" /> ' . $this->l('to') . ' <input type="text" id="reduction_to" name="reduction_to" value="' . (($to = $this->getFieldValue($obj, 'reduction_to') and $to != '0000-00-00' and $to != '1942-01-01') ? $to : date('Y-m-d')) . '" /> <p>' . $this->l('Leave same dates for undefined duration') . '</p> </td> </tr> <tr> <td class="col-left"> </td> <td style="padding-bottom:5px;"> <input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" /> <label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label> </td> </tr> <tr> <td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left">' . $this->l('Quantity:') . '</td> <td style="padding-bottom:5px;"><input size="3" maxlength="6" ' . $qty_state . ' name="quantity" type="text" value="' . $qty . '" ' . ((isset($_POST['attQty']) and $_POST['attQty']) ? 'onclick="alert(\'' . $this->l('Quantity is already defined by Attributes') . '.<br />' . $this->l('Delete attributes first') . '.\');" readonly="readonly" ' : '') . '/><sup> *</sup> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cavailable_now_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_now'); echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cavailable_later_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_later'); echo ' </td> </tr> <script type="text/javascript" src="../js/price.js"></script> <script type="text/javascript"> calcPriceTI(); </script> <tr> <td class="col-left">' . $this->l('When out of stock:') . '</td> <td style="padding-bottom:5px;"> <input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . (intval($this->getFieldValue($obj, 'out_of_stock')) == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l(intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')) ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . intval(Tab::getIdFromClassName('AdminPPreferences')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td> <td> <select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">'; $categories = Category::getCategories(intval($cookie->id_lang), false); Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_category_default') ? $this->getFieldValue($obj, 'id_category_default') : Tools::getValue('id_category', 1)); echo ' </select> </td> </tr> <tr> <td class="col-left">' . $this->l('Catalog:') . '</td> <td> <div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList"> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th> <th>' . $this->l('ID') . '</th> <th style="width: 400px">' . $this->l('Name') . '</th> </tr>'; $done = array(); $index = array(); $indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Product::getIndexedCategories($obj->id) : array()); foreach ($indexedCategories as $k => $row) { $index[] = $row['id_category']; } $this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, $obj->id_category_default); echo ' </table> <p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories in which product is to appear') . '<sup> *</sup></p> </div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr><td colspan="2"> <span onclick="javascript:openCloseLayer(\'seo\');" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br /> <div id="seo" style="display: none; padding-top: 15px;"> <table> <tr> <td class="col-left">' . $this->l('Meta title:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_title'); echo ' <p style="clear: both">' . $this->l('Product page title; leave blank to use product name') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta description:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_description_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_description'); echo ' <p style="clear: both">' . $this->l('A single sentence for HTML header') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta keywords:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_keywords_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_keywords'); echo ' <p style="clear: both">' . $this->l('Keywords for HTML header, separated by a comma') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Friendly URL:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="clink_rewrite_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'clink_rewrite'); global $cookie; $iso = Language::getIsoById(intval($cookie->id_lang)); echo ' <p style="clear: both; width: 360px; word-wrap: break-word; overflow: auto;">' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/id_product-<span id="friendly-url"></span>.html</p> </td> </tr> <script type="text/javascript">updateFriendlyURL();</script>'; echo '</td></tr></table> </div> </td></tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in search results') . ')</i></td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cdesc_short_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc_short'); echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Description:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cdesc_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc'); echo ' </td> </tr>'; echo '<tr><td class="col-left">' . $this->l('Tags:') . '</td><td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo '<div id="ctags_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '" value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"°{}_$%<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'ctags'); echo '<p style="clear: both">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>'; echo '</td> </tr>'; $accessories = Product::getAccessoriesLight(intval($cookie->id_lang), $obj->id); if ($postAccessories = Tools::getValue('inputAccessories')) { $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories')); foreach ($postAccessoriesTab as $accessoryId) { if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) { $accessories[] = $accessory; } } } echo ' <tr> <td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td> <td style="padding-bottom:5px;"> <div id="divAccessories">'; foreach ($accessories as $accessory) { echo $accessory['name'] . '<span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />'; } echo '</div> <input type="hidden" name="inputAccessories" id="inputAccessories" value="'; foreach ($accessories as $accessory) { echo $accessory['id_product'] . '-'; } echo '" /> <input type="hidden" name="nameAccessories" id="nameAccessories" value="'; foreach ($accessories as $accessory) { echo $accessory['name'] . '¤'; } echo '" /> <script type="text/javascript"> var formProduct; var accessories = new Array(); function fillAccessories() { $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductAccessories:1,id_lang:' . intval($cookie->id_lang) . ',id_product:' . ($obj->id ? intval($obj->id) : 0) . '}, function(j) { for (var i = 0; i < j.length; i++) accessories[i] = new Array(j[i].value, j[i].text); formProduct = document.layers ? document.forms.product : document.product; formProduct.selectAccessories.length = accessories.length + 1; for (i = 0, j = 1; i < accessories.length; i++) { if (formProduct.filter.value) if (accessories[i][1].toLowerCase().indexOf(formProduct.filter.value.toLowerCase()) == -1) continue; formProduct.selectAccessories.options[j].value = accessories[i][0]; formProduct.selectAccessories.options[j].text = accessories[i][1]; j++; } if (j == 1) { formProduct.selectAccessories.length = 2; formProduct.selectAccessories.options[1].value = -1; formProduct.selectAccessories.options[1].text = \'' . $this->l('No match found') . '\'; formProduct.selectAccessories.options.selectedIndex = 1; } else { formProduct.selectAccessories.length = j; formProduct.selectAccessories.options.selectedIndex = (formProduct.filter.value == \'\' ? 0 : 1); } } ); } </script> <select id="selectAccessories" name="selectAccessories" style="width: 380px;"> <option value="0" selected="selected">-- ' . $this->l('Choose') . ' --</option> </select> <script type="text/javascript"> fillAccessories(); </script> <span onclick="addAccessory();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" /></span> <br />' . $this->l('Filter:') . ' <input type="text" size="25" name="filter" onkeyup="fillAccessories();" class="space" /> </td> </tr> <tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:730px;"></td></tr> <tr> <td colspan="2" style="text-align:center;"> <input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" /> <input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td> </tr> </table> </div> <script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script> <script type="text/javascript"> function tinyMCEInit(element) { $().ready(function() { $(element).tinymce({ // Location of TinyMCE script script_url : \'' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/tiny_mce.js\', // General options theme : "advanced", plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen", // Theme options theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", width : "100", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, content_css : "' . __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/css/global.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js", elements : "nourlconvert", convert_urls : false, language : "' . (file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en') . '" }); }); } tinyMCEInit(\'textarea.rte\'); toggleVirtualProduct(getE(\'is_virtual_good\')); </script> '; }
/** * @param \Product $product * * @return string * @throws \PrestaShopException * @author Panagiotis Vagenas <*****@*****.**> * @since 150213 */ protected function getProductLink(\Product &$product) { $link = new \Link(); $pLink = $link->getProductLink($product); return urldecode($this->addHttp($pLink)); }
public function generate($to_file = true) { $link = new Link(); include_once 'YMarket.class.php'; //Язык по умолчанию $id_lang = intval(Configuration::get('PS_LANG_DEFAULT')); //Валюта по умолчанию $curr_def = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT'))); //создаем новый магазин $market = new YMarket($this->_settings['y_sn'], $this->_settings['y_fn'], 'http://' . Tools::getHttpHost(false, true), $this->_settings['y_ldc']); //Валюты if ($this->_settings['y_cu']) { $currencies = Currency::getCurrencies(); foreach ($currencies as $currency) { $market->add(new yCurrency($currency['iso_code'], floatval($currency['conversion_rate']))); } unset($currencies); } else { $market->add(new yCurrency($curr_def->iso_code, floatval($curr_def->conversion_rate))); } //Категории $categories = Category::getCategories($id_lang, false, false); foreach ($categories as $category) { $catdesc = $category['meta_title'] ? $category['meta_title'] : $category['name']; $market->add(new yCategory($category['id_category'], $catdesc, $category['id_parent'])); } unset($categories); //Продукты $products = self::getProducts($id_lang); while ($product = Db::getInstance()->nextRow($products)) { $tmp = new yOffer($product['id_product'], $product['name'], Product::getPriceStatic($product['id_product'], $usetax = true, NULL, $decimals = 2, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1, $forceAssociatedTax = true)); $tmp->id = $product['id_product']; $tmp->type = ''; $tmp->sales_notes = $this->_settings['y_sl']; $tmp->url = $link->getProductLink((int) $product['id_product'], $product['link_rewrite']); //Картинка if ($cover = self::getCover($product['id_product'])) { $tmp->picture = $link->getImageLink($product['link_rewrite'], $cover); } $tmp->currencyId = $curr_def->iso_code; $tmp->categoryId = $product['id_category_default']; //$tmp->vendorCode = $product['reference']; $tmp->description = $product['description']; if ($this->_settings['y_dl']) { $tmp->delivery = 'true'; } else { $tmp->delivery = 'false'; } switch ($this->_settings['y_av']) { case 1: $tmp->available = $product['quantity'] == 0 ? 'false' : 'true'; break; case 3: $tmp->available = 'false'; break; default: $tmp->available = 'true'; } //$tmp->barcode = $product['ean13']; if (ProductDownload::getIdFromIdProduct($product['id_product'])) { $tmp->downloadable = 'true'; } if (!($this->_settings['y_av'] == 2 and $product['quantity'] == 0)) { $market->add($tmp); } } if ($to_file) { $fp = fopen(dirname(__FILE__) . '/../../upload/yml.xml' . ($this->_settings['y_gz'] ? '.gz' : ''), 'w'); fwrite($fp, $market->generate(false, $this->_settings['y_gz'])); fclose($fp); } else { $market->generate(true, $this->_settings['y_gz']); } }
public function hookUpdateOrderStatus($var1) { /* Configuration status is reached */ if ($var1['newOrderStatus']->id == Configuration::get('feedaty_status_request')) { /* Load the order */ $order = new Order($var1['id_order']); /* Gets all products on order */ $products = $order->getProducts(); $final_products = array(); /* For each product we get picture, id, name, url */ foreach ($products as $product) { $tmp = array(); $id_image = Product::getCover($product['product_id']); if (count($id_image) > 0) { $image = new Image($id_image['id_image']); $tmp['ImageUrl'] = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image->getExistingImgPath() . '.jpg'; } $tmp['Id'] = $product['product_id']; $tmp['Name'] = $product['product_name']; $tmp['Brand'] = ''; $link = new Link(); $tmp['Url'] = $link->getProductLink((int) $product['product_id']); $final_products[] = $tmp; } /* Gets information about customer who made the order */ $customer = new Customer((int) $order->id_customer); /* Retrive also order date, customer email, id order, prestashop version and plugin version */ $tmp_order = array(); $tmp_order['OrderId'] = $var1['id_order']; $tmp_order['OrderDate'] = $order->date_add; $tmp_order['CustomerEmail'] = $customer->email; $tmp_order['CustomerId'] = $customer->email; $tmp_order['Platform'] = 'PrestaShop ' . _PS_VERSION_ . ' / ' . $this->version; $tmp_order['Products'] = $final_products; $js_data = array(); $js_data['merchantCode'] = Configuration::get('feedaty_code'); $js_data['orders'][] = $tmp_order; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://' . 'www.zoorate.com/ws/feedatyapi.svc/SubmitOrders'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, '60'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, Tools::jsonEncode($js_data)); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Expect:')); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_exec($ch); curl_close($ch); /* We don't need any responce, if worked ok so otherwise no problem */ } }
public function hookAdminStatsModules($params) { global $cookie; $categories = Category::getCategories(intval($cookie->id_lang), true, false); $productToken = Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)); $currency = Currency::getCurrency(Configuration::get('PS_CURRENCY_DEFAULT')); $link = new Link(); $irow = 0; if ($id_category = intval(Tools::getValue('id_category'))) { $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)'; $this->_where = 'AND cp.`id_category` = ' . $id_category; } $result1 = $this->getQuery1(true); $total = $result1['total']; $averagePrice = $result1['average_price']; $totalPictures = $result1['images']; $averagePictures = $total ? $totalPictures / $total : 0; $neverBought = $this->getProductsNB(intval($cookie->id_lang)); $totalNB = $neverBought['total']; $productsNB = $neverBought['result']; $totalBought = $this->getTotalBought(); $averagePurchase = $total ? $totalBought / $total : 0; $totalPageViewed = $this->getTotalPageViewed(); $averageViewed = $total ? $totalPageViewed / $total : 0; $conversion = number_format(floatval($totalPageViewed ? $totalBought / $totalPageViewed : 0), 2, '.', ''); if ($conversionReverse = number_format(floatval($totalBought ? $totalPageViewed / $totalBought : 0), 2, '.', '')) { $conversion .= ' (1 ' . $this->l('purchase') . ' / ' . $conversionReverse . ' ' . $this->l('visits') . ')'; } $totalNV = $total - $this->getTotalProductViewed(); $html = ' <script type="text/javascript" language="javascript">openCloseLayer(\'calendar\');</script> <fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend> <label> ' . $this->l('Choose a category') . ' </label> <div class="margin-form"> <form action="" method="post" id="categoriesForm"> <select name="id_category" onchange="$(\'#categoriesForm\').submit();"> <option value="0">' . $this->l('All') . '</option>'; foreach ($categories as $category) { $html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>'; } $html .= ' </select> </form> </div> <div class="clear space"></div> <table> ' . $this->returnLine($this->l('Products available:'), intval($total)) . ' ' . $this->returnLine($this->l('Average price (base price):'), Tools::displayPrice($averagePrice, $currency)) . ' ' . $this->returnLine($this->l('Product pages viewed:'), intval($totalPageViewed)) . ' ' . $this->returnLine($this->l('Products bought:'), intval($totalBought)) . ' ' . $this->returnLine($this->l('Average number of page visits:'), number_format(floatval($averageViewed), 2, '.', '')) . ' ' . $this->returnLine($this->l('Average number of purchases:'), number_format(floatval($averagePurchase), 2, '.', '')) . ' ' . $this->returnLine($this->l('Images available:'), intval($totalPictures)) . ' ' . $this->returnLine($this->l('Average number of images:'), number_format(floatval($averagePictures), 2, '.', '')) . ' ' . $this->returnLine($this->l('Products never viewed:'), intval($totalNV) . ' / ' . intval($total)) . ' ' . $this->returnLine('<a style="cursor : pointer" onclick="openCloseLayer(\'pnb\')">' . $this->l('Products never bought:') . '</a>', intval($totalNB) . ' / ' . intval($total)) . ' ' . $this->returnLine($this->l('Conversion rate*:'), $conversion) . ' </table> <div style="margin-top: 20px;"> <span style="color:red;font-weight:bold">*</span> ' . $this->l('Average conversion rate for the product page. It is possible to purchase a product without viewing the product page, so this rate can be greater than 1.') . ' </div> </fieldset>'; if (sizeof($productsNB) and sizeof($productsNB) < 50) { $html .= ' <fieldset class="width3 space"><legend><img src="../modules/' . $this->name . '/basket_delete.png" /> ' . $this->l('Products never bought') . '</legend> <table cellpadding="0" cellspacing="0" class="table"> <tr><th>' . $this->l('ID') . '</th><th>' . $this->l('Name') . '</th><th>' . $this->l('Edit / View') . '</th></tr>'; foreach ($productsNB as $product) { $html .= ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '> <td>' . $product['id_product'] . '</td> <td style="width: 400px;">' . $product['name'] . '</td> <td style="text-align: right"> <a href="index.php?tab=AdminCatalog&id_product=' . $product['id_product'] . '&addproduct&token=' . $productToken . '" target="_blank"><img src="../modules/' . $this->name . '/page_edit.png" /></a> <a href="' . $link->getProductLink($product['id_product'], $product['link_rewrite']) . '" target="_blank"><img src="../modules/' . $this->name . '/application_home.png" /></a> </td> </tr>'; } $html .= ' </table> </fieldset>'; } return $html; }
private function _postProcess() { $link = new Link(); $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); $ruBackup = $_SERVER['REQUEST_URI']; $snBackup = $_SERVER['SCRIPT_NAME']; $getBackup = $_GET; $xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> </urlset>'); $sitemap = $xml->addChild('url'); $sitemap->addChild('loc', 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__); $sitemap->addChild('priority', '1.00'); $sitemap->addChild('lastmod', date("Y-m-d")); $sitemap->addChild('changefreq', 'daily'); $cmss = Db::getInstance()->ExecuteS(' SELECT DISTINCT b.id_cms, cl.link_rewrite, cl.id_lang FROM ' . _DB_PREFIX_ . 'block_cms b LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'); foreach ($cmss as $cms) { $sitemap = $xml->addChild('url'); $tmpLink = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); $_GET = array('id_cms' => $cms['id_cms']); if ($cms['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($cms['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', '0.8'); $sitemap->addChild('changefreq', 'monthly'); } $categories = Db::getInstance()->ExecuteS(' SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1 ORDER BY cl.id_category, cl.id_lang ASC'); foreach ($categories as $category) { if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) { $priority = 0.1; } $sitemap = $xml->addChild('url'); $tmpLink = $link->getCategoryLink($category['id_category'], $category['link_rewrite']); $_GET = array('id_category' => $category['id_category']); if ($category['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($category['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', $priority); $sitemap->addChild('lastmod', substr($category['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'weekly'); } $products = Db::getInstance()->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, pl.id_lang, cl.`link_rewrite` AS category, ean13, ( SELECT MIN(level_depth) FROM ' . _DB_PREFIX_ . 'product p2 LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON p.id_product = pl.id_product LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON pl.id_lang = l.id_lang WHERE l.`active` = 1 AND p.`active` = 1 ORDER BY pl.id_product, pl.id_lang ASC'); foreach ($products as $product) { if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) { $priority = 0.1; } $sitemap = $xml->addChild('url'); $tmpLink = $link->getProductLink($product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13']); $_GET = array('id_product' => $product['id_product']); if ($product['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($product['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', $priority); $sitemap->addChild('lastmod', substr($product['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'weekly'); } $images = Db::getInstance()->ExecuteS(' SELECT * FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'image i ON p.id_product = i.id_product LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON i.id_image = il.id_image AND il.id_lang = ' . intval($defaultLanguage) . ' WHERE p.`active` = 1 ORDER BY p.id_product'); foreach ($images as $image) { $sitemap = $xml->addChild('url'); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $link->getImageLink(Tools::link_rewrite($image['legend']), $image['id_product'] . '-' . $image['id_image']); $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', 0.4); $sitemap->addChild('lastmod', substr($image['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'monthly'); } $xmlString = $xml->asXML(); $fp = fopen(GSITEMAP_FILE, 'w'); fwrite($fp, $xmlString, Tools::strlen($xmlString)); fclose($fp); $res = file_exists(GSITEMAP_FILE); $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">'; $this->_html .= $res ? $this->l('Sitemap file successfully generated') : $this->l('Error while creating sitemap file'); $this->_html .= '</h3>'; $_SERVER['REQUEST_URI'] = $ruBackup; $_SERVER['SCRIPT_NAME'] = $snBackup; $_GET = $getBackup; }
/** * Builds a product page url for the language and shop. * * We created our own method due to the existing one in `LinkCore` behaving differently across PS versions. * * @param Product|ProductCore $product * @param int|null $id_lang the language ID (falls back on current context if not set). * @param int|null $id_shop the shop ID (falls back on current context if not set). * @param array $params additional params to add to the url. * @return string the product page url. */ public function getProductUrl($product, $id_lang = null, $id_shop = null, array $params = array()) { if (is_null($id_lang)) { $id_lang = (int) Context::getContext()->language->id; } if (is_null($id_shop)) { $id_shop = (int) Context::getContext()->shop->id; } if (version_compare(_PS_VERSION_, '1.5.0.0') === -1 || version_compare(_PS_VERSION_, '1.5.5.0') >= 0) { /** @var LinkCore $link */ $link = new Link(); $url = $link->getProductLink($product, null, null, null, $id_lang, $id_shop); } else { // For PS versions 1.5.0.0 - 1.5.4.1 we always hard-code the urls to be in non-friendly format and fetch // the shops base url ourselves. This is a workaround to all the bugs related to url building in these // PS versions. $query_params = array('id_product' => (int) $product->id, 'controller' => 'product', 'id_lang' => $id_lang); $url = $this->getBaseUrl($id_shop) . 'index.php?' . http_build_query($query_params); } if ((int) Configuration::get('PS_REWRITING_SETTINGS') === 0) { $params['id_lang'] = $id_lang; } return NostoHttpRequest::replaceQueryParamsInUrl($params, $url); }
<?php include_once '../../config/config.inc.php'; include_once '../../init.php'; //$this->instant_search = Tools::getValue('instantSearch'); //$this->ajax_search = Tools::getValue('ajaxSearch'); //parent::initContent(); $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q'))); $original_query = Tools::getValue('q'); $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true); foreach ($searchResults as &$product) { //$product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); $links = new Link(); $product['product_link'] = $links->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); /** *Get product cover */ $tdgetpover = Product::getCover($product['id_product']); $cproduct_image = new Image($tdgetpover['id_image']); $cproductimg_url = $cproduct_image->getExistingImgPath() . '-small_default.jpg'; $product['ajaxsearchimage'] = $cproductimg_url; } die(Tools::jsonEncode($searchResults));
private function getProductLink($product_id) { $link = $this->context->link; if (isset($link) && method_exists($link, 'getProductLink')) { return $link->getProductLink((int) $product_id); } else { $link = new Link(); return $link->getProductLink((int) $product_id); } }
public static function sendCustomerAlert($id_product, $id_product_attribute) { $link = new Link(); $id_lang = (int) Context::getContext()->language->id; $product = new Product((int) $id_product, false, $id_lang); $templateVars = array('{product}' => is_array($product->name) ? $product->name[$id_lang] : $product->name, '{product_link}' => $link->getProductLink($product)); $customers = self::getCustomers($id_product, $id_product_attribute); foreach ($customers as $customer) { if ($customer['id_customer']) { $customer = new Customer((int) $customer['id_customer']); $customer_email = $customer->email; $customer_id = (int) $customer->id; } else { $customer_id = 0; $customer_email = $customer['customer_email']; } $iso = Language::getIsoById($id_lang); if (file_exists(dirname(__FILE__) . '/mails/' . $iso . '/customer_qty.txt') && file_exists(dirname(__FILE__) . '/mails/' . $iso . '/customer_qty.html')) { Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'customer_qty', Mail::l('Product available', $id_lang), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__) . '/mails/'); } Hook::exec('actionModuleMailAlertSendCustomer', array('product' => is_array($product->name) ? $product->name[$id_lang] : $product->name, 'link' => $link->getProductLink($product))); self::deleteAlert((int) $customer_id, strval($customer_email), (int) $id_product, (int) $id_product_attribute); } }
public function sendEmailResponseConfirmation($object) { if (!Validate::isEmail($object->email)) { return false; } $consulta = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'lgconsultas` WHERE id_consulta=' . (int) $object->id); $producto = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'product_lang WHERE id_product=' . (int) $consulta['id_producto'] . ' AND id_lang=' . (int) Configuration::get('PS_LANG_DEFAULT')); $enlace = new Link(); $urlproducto = $enlace->getProductLink($consulta['id_producto']); $templateVars = array('id_consulta' => $object->id, '{name}' => $object->nombre, '{consulta}' => $object->consulta, '{respuesta}' => $object->response->respuesta, '{producto}' => $producto, '{urlproducto}' => $urlproducto); if (!Mail::Send((int) $this->context->language->id, 'respuesta_enviada', sprintf(Mail::l('You have received an answer to your question', (int) $this->context->language->id), Configuration::get('PS_SHOP_EMAIL')), $templateVars, $object->email, null, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . $this->module->name . '/mails/')) { $res = false; } else { $res = true; } return $res; }
public function getLink($menu) { if ($this->edit_string) { return '#'; } $link = new Link(); $id_lang = Context::getContext()->language->id; $value = (int) $menu['item']; $result = ''; switch ($menu['type']) { case 'product': if (Validate::isLoadedObject($obj_pro = new Product($value, true, $id_lang))) { $result = $link->getProductLink((int) $obj_pro->id, $obj_pro->link_rewrite, null, null, $id_lang); } break; case 'category': if (Validate::isLoadedObject($obj_cate = new Category($value, $id_lang))) { $result = $link->getCategoryLink((int) $obj_cate->id, $obj_cate->link_rewrite, $id_lang); } break; case 'cms': if (Validate::isLoadedObject($obj_cms = new CMS($value, $id_lang))) { $result = $link->getCMSLink((int) $obj_cms->id, $obj_cms->link_rewrite, $id_lang); } break; case 'url': $value = $menu['url']; if ($value == 'index' || $value == 'index.php') { $result = $link->getPageLink('index.php', false, $id_lang); break; } $regex = '((https?|ftp)\\:\\/\\/)?'; // SCHEME $regex .= '([a-z0-9+!*(),;?&=\\$_.-]+(\\:[a-z0-9+!*(),;?&=\\$_.-]+)?@)?'; // User and Pass $regex .= '([a-z0-9-.]*)\\.([a-z]{2,3})'; // Host or IP $regex .= '(\\:[0-9]{2,5})?'; // Port $regex .= '(\\/([a-z0-9+\\$_-]\\.?)+)*\\/?'; // Path $regex .= '(\\?[a-z+&\\$_.-][a-z0-9;:@&%=+\\/\\$_.-]*)?'; // GET Query $regex .= '(#[a-z_.-][a-z0-9+\\$_.-]*)?'; // Anchor if ($value == '#' || preg_match("/^{$regex}\$/", $value)) { $result = $value; break; } $result = $link->getPageLink($value, false, $id_lang); break; case 'manufacture': if (Validate::isLoadedObject($obj_manu = new Manufacturer($value, $id_lang))) { $result = $link->getManufacturerLink((int) $obj_manu->id, $obj_manu->link_rewrite, $id_lang); } break; case 'supplier': if (Validate::isLoadedObject($obj_supp = new Supplier($value, $id_lang))) { $result = $link->getSupplierLink((int) $obj_supp->id, $obj_supp->link_rewrite, $id_lang); } break; default: $result = '#'; break; } return $result; }
public function hookDisplayProductListReviews($params) { $id_product = (int) $params['product']['id_product']; $product = new Product($id_product); $link = new Link(); $url = $link->getProductLink($product); //echo $id_product; //$result = array(); //$sql = Db::getInstance()->getValue('SELECT `price` FROM '._DB_PREFIX_.'_product_attribute WHERE id_product = 18 AND id_product_attribute = 110'); if (!$this->isCached('productcomments_reviews.tpl', $this->getCacheId($id_product))) { require_once dirname(__FILE__) . '/ProductComment.php'; $average = ProductComment::getAverageGrade($id_product); $this->smarty->assign(array('product' => $params['product'], 'averageTotal' => round($average['grade']), 'ratings' => ProductComment::getRatings($id_product), 'nbComments' => (int) ProductComment::getCommentNumber($id_product), 'url' => $url)); } //echo $id_product."<br />"; //echo($result); return $this->display(__FILE__, 'productcomments_reviews.tpl', $this->getCacheId($id_product)); }
private function _postProcess() { Configuration::updateValue('GSITEMAP_ALL_CMS', (int) Tools::getValue('GSITEMAP_ALL_CMS')); Configuration::updateValue('GSITEMAP_ALL_PRODUCTS', (int) Tools::getValue('GSITEMAP_ALL_PRODUCTS')); $link = new Link(); $langs = Language::getLanguages(); $xmlString = <<<XML <?xml version="1.0" encoding="UTF-8" ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"> </urlset> XML; $xml = new SimpleXMLElement($xmlString); if (Configuration::get('PS_REWRITING_SETTINGS') and sizeof($langs) > 1) { foreach ($langs as $lang) { $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__ . $lang['iso_code'] . '/', '1.00', 'daily', date('Y-m-d')); } } else { $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__, '1.00', 'daily', date('Y-m-d')); } /* CMS Generator */ if (Configuration::get('GSITEMAP_ALL_CMS') or !Module::isInstalled('blockcms')) { $sql_cms = ' SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_lang cl LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } elseif (Module::isInstalled('blockcms')) { $sql_cms = ' SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_block_page b LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } $cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms); foreach ($cmss as $cms) { $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int) $cms['id_cms'], $cms['link_rewrite'], false, (int) $cms['id_lang']) : $link->getCMSLink((int) $cms['id_cms']); $this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily'); } /* Categories Generator */ if (Configuration::get('PS_REWRITING_SETTINGS')) { $categories = Db::getInstance()->ExecuteS(' SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1 ORDER BY cl.id_category, cl.id_lang ASC'); } else { $categories = Db::getInstance()->ExecuteS('SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd FROM ' . _DB_PREFIX_ . 'category c ORDER BY c.id_category ASC'); } foreach ($categories as $category) { if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCategoryLink((int) $category['id_category'], $category['link_rewrite'], (int) $category['id_lang']) : $link->getCategoryLink((int) $category['id_category']); $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10)); } $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, ( SELECT MIN(level_depth) FROM ' . _DB_PREFIX_ . 'product p2 LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'image i ON p.id_product = i.id_product LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND pl.`id_lang` = il.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (pl.id_lang = l.id_lang) WHERE l.`active` = 1 AND p.`active` = 1 ' . (Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL') . ' ORDER BY pl.id_product, pl.id_lang ASC'); $tmp = null; $res = null; foreach ($products as $product) { if ($tmp == $product['id_product']) { $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); } else { $tmp = $product['id_product']; $res[$tmp] = $product; unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']); $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); } } foreach ($res as $product) { if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']); $sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10)); $sitemap = $this->_addSitemapNodeImage($sitemap, $product); } /* Add classic pages (contact, best sales, new products...) */ $pages = array('authentication' => true, 'best-sales' => false, 'contact-form' => true, 'discount' => false, 'index' => false, 'manufacturer' => false, 'new-products' => false, 'prices-drop' => false, 'supplier' => false, 'store' => false); // Don't show suppliers and manufacturers if they are disallowed if (!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) { unset($pages['manufacturer']); } if (!Module::getInstanceByName('blocksupplier')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) { unset($pages['supplier']); } // Generate nodes for pages if (Configuration::get('PS_REWRITING_SETTINGS')) { foreach ($pages as $page => $ssl) { foreach ($langs as $lang) { $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl, $lang['id_lang']), '0.5', 'monthly'); } } } else { foreach ($pages as $page => $ssl) { $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl), '0.5', 'monthly'); } } $xmlString = $xml->asXML(); $fp = fopen(GSITEMAP_FILE, 'w'); fwrite($fp, $xmlString); fclose($fp); $res = file_exists(GSITEMAP_FILE); $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">'; $this->_html .= $res ? $this->l('Sitemap file generated') : $this->l('Error while creating sitemap file'); $this->_html .= '</h3>'; }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (!$this->errors) { $webservice_exi = new SoapClient('http://www2.promoshop.com.mx/ws_store/service.asmx?WSDL'); $parameter = array("ItemNumber" => $this->product->item_number, "key" => EXIMAGEN_KEY); $inventory = $webservice_exi->GetInventory($parameter); if (isset($inventory->GetInventoryResult->InventoryData->SKU)) { $inventory = $inventory->GetInventoryResult; } else { $inventory = $inventory->GetInventoryResult->InventoryData; } $quote_table = ""; $decoration_list = ''; $decoration = json_decode($this->product->decoration_details); if (!isset($decoration->areasimp->ItemNumber)) { $decoration = $decoration->areasimp; } foreach ($decoration as $deco) { $decoration_list .= $deco->TecnicaFull . ', '; } $decoration_list = substr($decoration_list, 0, -2); if ($this->product->quick_quote != '') { $quote = json_decode($this->product->quick_quote); //var_dump($this->product->quick_quote); foreach ($quote->PricesArray->Prices as $price) { $quote_table .= "<tr><td>" . $price->Piezas; $precio = explode('.', $price->Precio); $precio_imp = explode('.', $price->PrecioImp); if (intval($price->Piezas) < 10) { $quote_table .= " Muestra"; } else { $quote_table .= " Piezas"; } $quote_table .= "</td>"; $quote_table .= "<td>\$" . $precio[0] . "." . substr($precio[1], 0, 2) . "</td>"; $quote_table .= "<td>\$" . $precio_imp[0] . "." . substr($precio_imp[1], 0, 2) . "</td></tr>"; } } $link = new Link(); $productUrl = $link->getProductLink($this->product); $margin = Configuration::get('PROFIT_MARGIN'); $price_type = Configuration::get('PRODUCT_DYNAMIC_PRICE'); if (isset($margin) && $price_type == 1) { $margin = floatval($margin) / 100; $margin = 1 - $margin; $this->product->base_price = $this->product->base_price / $margin; } 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(); } 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.'); } } $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; $customizationFields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false; if (is_array($customizationFields)) { foreach ($customizationFields as $customizationField) { if ($this->product->customization_required = $customizationField['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 = $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' => $customizationFields, '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', 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)), 'HOOK_PRODUCT_FILE_CONTENT' => Hook::exec('productFileContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE' => Hook::exec('productFile', array('product' => $this->product)), 'HOOK_CUSTOM_QUOTE' => Hook::exec('displayProductcustomquote', array('product' => $this->product, 'customizationFields' => $customizationFields)), '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'), 'errors' => $this->errors, 'quote_table_detail' => $quote_table, 'inventory' => $inventory, 'decoration_list' => $decoration_list, 'product_url' => $productUrl, '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'); }
/** * @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; }
public function sendCustomerAlert($id_product, $id_product_attribute) { global $cookie, $link; $link = new Link(); $customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT id_customer, customer_email FROM `' . _DB_PREFIX_ . 'mailalert_customer_oos` WHERE `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute); $product = new Product((int) $id_product, false, (int) $cookie->id_lang); $templateVars = array('{product}' => is_array($product->name) ? $product->name[(int) Configuration::get('PS_LANG_DEFAULT')] : $product->name, '{product_link}' => $link->getProductLink($product)); foreach ($customers as $cust) { if ($cust['id_customer']) { $customer = new Customer((int) $cust['id_customer']); $customer_email = $customer->email; $customer_id = (int) $customer->id; } else { $customer_email = $cust['customer_email']; $customer_id = 0; } $id_lang = (is_object($cookie) and isset($cookie->id_lang)) ? (int) $cookie->id_lang : (int) Configuration::get('PS_LANG_DEFAULT'); $iso = Language::getIsoById((int) $id_lang); if (file_exists(dirname(__FILE__) . '/mails/' . $iso . '/customer_qty.txt') and file_exists(dirname(__FILE__) . '/mails/' . $iso . '/customer_qty.html')) { Mail::Send((int) Configuration::get('PS_LANG_DEFAULT'), 'customer_qty', Mail::l('Product available'), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__) . '/mails/'); } if ($customer_id) { $customer_email = 0; } self::deleteAlert((int) $customer_id, strval($customer_email), (int) $id_product, (int) $id_product_attribute); } }