function sendCartMails() { global $link; $sql = "SELECT c.id_cart, cc.email, cc.`firstname`, cc.id_customer\n\tFROM `ps_cart` c\n\tINNER JOIN ps_customer cc ON cc.`id_customer` = c.`id_customer`\n\tINNER JOIN `ps_cart_product` cp ON cp.`id_cart` = c.id_cart\n\tLEFT JOIN ps_orders o ON o.`id_cart` = c.id_cart\n\tWHERE o.id_cart IS NULL\n\tAND datediff(curdate(), c.`date_upd`) = 3\n\tAND cc.newsletter = 0\n\tGROUP BY cc.`id_customer`"; /*$sql = "SELECT c.id_cart, cc.email, cc.`firstname`, cc.id_customer FROM `ps_cart` c INNER JOIN ps_customer cc ON cc.`id_customer` = c.`id_customer` INNER JOIN `ps_cart_product` cp ON cp.`id_cart` = c.id_cart LEFT JOIN ps_orders o ON o.`id_cart` = c.id_cart WHERE cc.id_customer = 1 GROUP BY cc.`id_customer`";*/ $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); $count = 0; foreach ($res as $row) { $count++; $id_cart = Cart::lastNoneOrderedCart($row['id_customer']); $cart = new Cart($id_cart); $id_product = $cart->getLastProduct(); $id_product = $id_product['id_product']; $product = new Product($id_product, true, 1); $idImage = $product->getCoverWs(); if ($idImage) { $idImage = $product->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $templateVars = array(); $templateVars['{firstname}'] = $row['firstname']; $templateVars['{product_url}'] = $product->getLink(); $templateVars['{product_name}'] = $product->name; $templateVars['{image_link}'] = $link->getImageLink($product->link_rewrite, $idImage, 'list'); $mailTo = $row['email']; echo "" . $count . " : " . $mailTo . "\n"; $subject = $row['firstname'] . ", you left your shopping bag with us"; @Mail::Send(1, 'abandoned', $subject, $templateVars, $mailTo, $row['firstname'], '*****@*****.**', 'Indusdiva.com', NULL, NULL, _PS_MAIL_DIR_, false); usleep(200000); } }
function sendWishlistMails() { global $link; $sql = "SELECT w.id_product, cc.email, cc.`firstname`, cc.id_customer\n\tFROM `ps_wishlist` w\n\tINNER JOIN ps_customer cc ON cc.`id_customer` = w.`id_customer`\n\tINNER JOIN ps_product p ON p.id_product = w.id_product\n\tLEFT JOIN ps_orders o ON o.`id_customer` = cc.`id_customer`\n\tWHERE o.id_customer IS NULL\n\tAND p.`quantity` > 0\n\tAND p.active = 1\n\tAND cc.newsletter = 0\n\tOR cc.id_customer = 1\n\tGROUP BY cc.`id_customer`"; /*$sql = "SELECT w.id_product, cc.email, cc.`firstname`, cc.id_customer FROM `ps_wishlist` w INNER JOIN ps_customer cc ON cc.`id_customer` = w.`id_customer` INNER JOIN ps_product p ON p.id_product = w.id_product LEFT JOIN ps_orders o ON o.`id_customer` = cc.`id_customer` WHERE cc.id_customer in (1) AND p.`quantity` > 0 AND p.active = 1 GROUP BY cc.`id_customer`";*/ $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); $count = 0; foreach ($res as $row) { $count++; $id_product = $row['id_product']; $product = new Product($id_product, true, 1); $idImage = $product->getCoverWs(); if ($idImage) { $idImage = $product->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $templateVars = array(); $templateVars['{firstname}'] = $row['firstname']; $templateVars['{product_url}'] = $product->getLink(); $templateVars['{product_name}'] = $product->name; $templateVars['{image_link}'] = $link->getImageLink($product->link_rewrite, $idImage, 'list'); $mailTo = $row['email']; echo "" . $count . " : " . $mailTo . "\n"; $subject = $row['firstname'] . ", Let your Wishlist Come True"; @Mail::Send(1, 'wishlistreminder', $subject, $templateVars, $mailTo, $row['firstname'], '*****@*****.**', 'Indusdiva.com', NULL, NULL, _PS_MAIL_DIR_, true); usleep(200000); } }
protected function makeMenu() { $root_node = $this->makeNode(['label' => null, 'type' => 'root', 'children' => []]); $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $categories = $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups)); $root_node['children'] = array_merge($root_node['children'], $categories); break; case 'PRD': $product = new Product((int) $id, true, (int) $id_lang); if ($product->id) { $root_node['children'][] = $this->makeNode(['type' => 'product', 'page_identifier' => 'product-' . $product->id, 'label' => $product->name, 'url' => $product->getLink()]); } break; case 'CMS': $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $root_node['children'][] = $this->makeNode(['type' => 'cms-page', 'page_identifier' => 'cms-page-' . $id, 'label' => $cms[0]['meta_title'], 'url' => $cms[0]['link']]); } break; case 'CMS_CAT': $root_node['children'][] = $this->generateCMSCategoriesMenu((int) $id, (int) $id_lang); break; // Case to handle the option to show all Manufacturers // Case to handle the option to show all Manufacturers case 'ALLMAN': $children = array_map(function ($manufacturer) use($id_lang) { return $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer['id_manufacturer'], 'label' => $manufacturer['name'], 'url' => $this->context->link->getManufacturerLink(new Manufacturer($manufacturer['id_manufacturer'], $id_lang), null, $id_lang)]); }, Manufacturer::getManufacturers()); $root_node['children'][] = $this->makeNode(['type' => 'manufacturers', 'page_identifier' => 'manufacturers', 'label' => $this->l('All manufacturers'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $children]); break; case 'MAN': $manufacturer = new Manufacturer($id, $id_lang); if ($manufacturer->id) { $root_node['children'][] = $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer->id, 'label' => $manufacturer->name, 'url' => $this->context->link->getManufacturerLink($manufacturer, null, $id_lang)]); } break; // Case to handle the option to show all Suppliers // Case to handle the option to show all Suppliers case 'ALLSUP': $children = array_map(function ($supplier) use($id_lang) { return $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier['id_supplier'], 'label' => $supplier['name'], 'url' => $this->context->link->getSupplierLink(new Supplier($supplier['id_supplier'], $id_lang), null, $id_lang)]); }, Supplier::getSuppliers()); $root_node['children'][] = $this->makeNode(['type' => 'suppliers', 'page_identifier' => 'suppliers', 'label' => $this->l('All suppliers'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $children]); break; case 'SUP': $supplier = new Supplier($id, $id_lang); if ($supplier->id) { $root_node['children'][] = $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier->id, 'label' => $supplier->name, 'url' => $this->context->link->getSupplierLink($supplier, null, $id_lang)]); } break; case 'SHOP': $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $root_node['children'][] = $this->makeNode(['type' => 'shop', 'page_identifier' => 'shop-' . $id, 'label' => $shop->name, 'url' => $shop->getBaseURL()]); } break; case 'LNK': $link = Ps_MenuTopLinks::get($id, $id_lang, $id_shop); if (!empty($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = Ps_MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); } $root_node['children'][] = $this->makeNode(['type' => 'link', 'page_identifier' => $link[0]['link'], 'label' => $link[0]['label'], 'url' => $link[0]['link'], 'open_in_new_window' => $link[0]['new_window']]); } break; } } return $this->mapTree(function ($node, $depth) { $node['depth'] = $depth; return $node; }, $root_node); }
public function postProcess() { global $currentIndex, $cookie, $smarty; if (Tools::getValue('approve')) { $id_comment = Tools::getValue('reviewID'); $comment = new ProductComment((int) $id_comment); $comment->validate = 1; $comment->update(); $product = new Product($comment->id_product, true, (int) $cookie->id_lang); $customer = new Customer($comment->id_customer); //send mail notifications Mail::Send((int) $cookie->id_lang, 'review_approved', Mail::l('Your product review for ' . $product->name), array('{product_name}' => $product->name, '{firstname}' => $customer->firstname, '{product_url}' => $product->getLink()), $customer->email, $customer->firstname . ' ' . $customer->lastname); //queue reward rule exec if (!product_review_approved::rewardExistsForReference($comment->id_customer, EVENT_REVIEW_APPROVED, 3, $comment->id_product)) { Tools::sendSQSRuleMessage(EVENT_REVIEW_APPROVED, $comment->id_product, $comment->id_customer, date('Y-m-d H:i:s')); } } if (Tools::getValue('disapprove')) { $id_comment = Tools::getValue('reviewID'); $comment = new ProductComment((int) $id_comment); $comment->deleted = 1; $comment->update(); $product = new Product($comment->id_product, true, (int) $cookie->id_lang); $customer = new Customer($comment->id_customer); //send mail notifications Mail::Send((int) $cookie->id_lang, 'review-reject', Mail::l('Your product review for ' . $product->name), array('{product_name}' => $product->name, '{firstname}' => $customer->firstname, '{product_url}' => $product->getLink()), $customer->email, $customer->firstname . ' ' . $customer->lastname); } if (Tools::getValue('restore')) { $id_comment = Tools::getValue('reviewID'); $comment = new ProductComment((int) $id_comment); $comment->deleted = 0; $comment->update(); } if (Tools::getValue('editReview')) { $id_comment = Tools::getValue('reviewID'); $reviewContent = Tools::getValue('reviewContent'); $reviewTitle = Tools::getValue('reviewTitle'); $comment = new ProductComment((int) $id_comment); $comment->content = $reviewContent; $comment->title = $reviewTitle; $comment->validate = Tools::getValue('approveReview') ? 1 : 0; $product = new Product($comment->id_product, true, (int) $cookie->id_lang); $customer = new Customer($comment->id_customer); if ($comment->validate) { //queue reward rule exec if (!product_review_approved::rewardExistsForReference($comment->id_customer, EVENT_REVIEW_APPROVED, 3, $comment->id_product)) { Tools::sendSQSRuleMessage(EVENT_REVIEW_APPROVED, $comment->id_product, $comment->id_customer, date('Y-m-d H:i:s')); } //send mail notifications Mail::Send((int) $cookie->id_lang, 'review_approved', Mail::l('Your product review for ' . $product->name), array('{product_name}' => $product->name, '{firstname}' => $customer->firstname, '{product_url}' => $product->getLink()), $customer->email, $customer->firstname . ' ' . $customer->lastname); } $comment->update(); } if (Tools::getValue('view')) { $id_comment = Tools::getValue('reviewID'); $comment = new ProductComment((int) $id_comment); $smarty->assign('review', $comment); } $p = (int) Tools::getValue('p', 1); $n = Tools::getValue('n', 20); $totalReviews = ProductComment::getTotalComments(); $pages = $totalReviews / $n; if ($totalReviews > $n) { $smarty->assign('pages', $pages); } $comments = ProductComment::getComments($p, $n); $smarty->assign('reviews', $comments); $smarty->assign('currentIndex', $currentIndex); $smarty->assign('token', $this->token); $smarty->assign('customerToken', Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee)); }
protected function generateUrl($value, $default = "#", $prefix = '') { $response = $default; if ($prefix) { $value .= $prefix; } if ($value) { $langId = $this->context->language->id; $shopId = $this->context->shop->id; $arr = explode('|', $value); switch ($arr[0]) { case 'PRD': $product = new Product((int) $arr[1], true, (int) $langId); $response = Tools::HtmlEntitiesUTF8($product->getLink()); break; case 'CAT': $response = Tools::HtmlEntitiesUTF8($this->context->link->getCategoryLink((int) $arr[1], null, $langId)); break; case 'CMS_CAT': $response = Tools::HtmlEntitiesUTF8($this->context->link->getCMSCategoryLink((int) $arr[1], null, $langId)); break; case 'CMS': $response = Tools::HtmlEntitiesUTF8($this->context->link->getCMSLink((int) $arr[1], null, $langId)); break; case 'ALLMAN': $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink('manufacturer'), true, $langId); break; case 'MAN': $man = new Manufacturer((int) $arr[1], $langId); $response = Tools::HtmlEntitiesUTF8($this->context->link->getManufacturerLink($man->id, $man->link_rewrite, $langId)); break; case 'ALLSUP': $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink('supplier'), true, $langId); break; case 'SUP': $sup = new Supplier((int) $arr[1], $langId); $response = Tools::HtmlEntitiesUTF8($this->context->link->getSupplierLink($sup->id, $sup->link_rewrite, $langId)); break; case 'SHO': $shop = new Shop((int) $key); $response = $shop->getBaseURL(); break; case 'PAG': $pag = Meta::getMetaByPage($arr[1], $langId); if (strpos($pag['page'], 'module-') === false) { $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink($pag['page'], true, $langId)); } else { $page = explode('-', $pag['page']); Context::getContext()->link->getModuleLink($page[1], $page[2]); $response = Tools::HtmlEntitiesUTF8($this->context->link->getModuleLink($page[1], $page[2])); } break; default: break; } } return $response; }
private function makeMobileMenu($item) { $listofthisfrontmenu = ''; $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); preg_match($this->pattern, $item, $values); $id = (int) substr($item, strlen($values[1]), strlen($item)); switch (substr($item, 0, strlen($values[1]))) { case 'CAT': $this->_mmenu .= $this->getCatMobileOption((int) $id); break; case 'PRD': $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : ''; $product = new Product((int) $id, true, (int) $id_lang); if (!is_null($product->id)) { $this->_mmenu .= '<option value="' . $product->getLink() . '">' . $product->name . '</option>' . PHP_EOL; } break; case 'CMS': $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? '' : ''; $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $this->_mmenu .= '<option value="' . $cms[0]['link'] . '">' . $cms[0]['meta_title'] . '</option>' . PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int) $id, (int) $id_lang); if (count($category)) { $this->_mmenu .= '<option value="' . $category->getLink() . '"><span class="errow"></span><span>' . $category->name . '</option>'; $this->getCMSMenuItems($category->id); } break; case 'MAN': $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int) $id, (int) $id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_mmenu .= '<option value="' . htmlentities($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '">' . $manufacturer->name . '</option>' . PHP_EOL; } break; case 'SUP': $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : ''; $supplier = new Supplier((int) $id, (int) $id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_mmenu .= '<option value="' . $link->getSupplierLink((int) $id, $supplier->link_rewrite) . '">' . $supplier->name . '</option>' . PHP_EOL; } break; case 'LNK': $link = TdMegaMenu::getCustomLinksByid((int) $id, (int) $id_lang, (int) $id_shop); if (count($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = TdMegaMenu::getCustomLinksByid($link[0]['id_tdmegamenu'], (int) $default_language, (int) Shop::getContextShopID()); } $listofthisfrontmenu .= '<option value="' . $link[0]['menu_link'] . '">' . $link[0]['menu_title'] . '</option>' . PHP_EOL; if ($link[0]['custome_type'] == 'cus_html') { $this->_mmenu .= html_entity_decode($link[0]['description']); } } break; case 'SHOP': $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : ''; $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $link = new Link(); $this->_mmenu .= '<option value="' . $shop->getBaseURL() . '">' . $shop->name . '</option>' . PHP_EOL; } break; } return $listofthisfrontmenu; }
public static function generationUrl() { $value = Tools::getValue('value'); $response = ''; if ($value) { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $arr = explode('-', $value); switch ($arr[0]) { case 'PRD': $product = new Product((int) $arr[1], true, (int) $langId); $response = Tools::HtmlEntitiesUTF8($product->getLink()); break; case 'CAT': $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCategoryLink((int) $arr[1], null, $langId)); break; case 'CMS_CAT': $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCMSCategoryLink((int) $arr[1], null, $langId)); break; case 'CMS': $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCMSLink((int) $arr[1], null, $langId)); break; case 'ALLMAN': $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink('manufacturer'), true, $langId); break; case 'MAN': $man = new Manufacturer((int) $arr[1], $langId); $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getManufacturerLink($man->id, $man->link_rewrite, $langId)); break; case 'ALLSUP': $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink('supplier'), true, $langId); break; case 'SUP': $sup = new Supplier((int) $arr[1], $langId); $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getSupplierLink($sup->id, $sup->link_rewrite, $langId)); break; case 'PAG': $pag = Meta::getMetaByPage($arr[1], $langId); $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink($pag['page'], true, $langId)); break; case 'SHO': $shop = new Shop((int) $key); $response = $shop->getBaseURL(); break; default: $response = '#'; break; } } else { $response = '#'; } die(Tools::jsonEncode($response)); }
public function process() { global $cart, $currency; parent::process(); if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) { $this->errors[] = Tools::displayError('Product not found'); } else { if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) { header('HTTP/1.1 404 page not found'); $this->errors[] = Tools::displayError('Product is no longer available.'); } elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this product.'); } else { self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id)); if (!$this->product->active) { self::$smarty->assign('adminActionDisplay', true); } /* rewrited url set */ $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite); /* Product pictures management */ require_once 'images.inc.php'; self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if (Tools::isSubmit('submitCustomizedDatas')) { $this->pictureUpload($this->product, $cart); $this->textRecord($this->product, $cart); $this->formTargetFormat(); } elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) { $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture'); } $files = self::$cookie->getFamily('pictures_' . (int) $this->product->id); $textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id); foreach ($textFields as $key => $textField) { $textFields[$key] = str_replace('<br />', "\n", $textField); } self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields)); if ((int) Tools::getValue('pp') == 1) { echo 'here1'; } $productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) { $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); } if ((int) Tools::getValue('pp') == 1) { $time2 = time(); echo 'time2: ' . $time2; } $productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax); $configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES')); /* Features / Values */ $features = $this->product->getFrontFeatures((int) self::$cookie->id_lang); $attachments = $this->product->getAttachments((int) self::$cookie->id_lang); /* Category */ $category = false; if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) { if (isset($regs[2]) and is_numeric($regs[2])) { if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) { $category = new Category((int) $regs[2], (int) self::$cookie->id_lang); } } elseif (isset($regs[5]) and is_numeric($regs[5])) { if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) { $category = new Category((int) $regs[5], (int) self::$cookie->id_lang); } } } if (!$category) { $category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang); } if (isset($category) and Validate::isLoadedObject($category)) { self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name))); } else { self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name)); } self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();'); $lang = Configuration::get('PS_LANG_DEFAULT'); if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) { $this->product->quantity = 0; } $group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100; $id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0; $id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT')); if ((int) Tools::getValue('pp') == 1) { $time3 = time(); echo 'time3: ' . $time3; } // Tax $tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); self::$smarty->assign('tax_rate', $tax); $ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2); if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) { $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2); } $manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1); $sizechart = new Sizechart((int) $this->product->id_sizechart, 1); //see if the product is already in the wishlist if ($id_customer) { $sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id; $res = Db::getInstance()->ExecuteS($sql); if ($res) { self::$smarty->assign("in_wishlist", true); } else { self::$smarty->assign("in_wishlist", false); } } else { self::$smarty->assign("in_wishlist", false); } self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => $manufacturer, 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) $configs['PS_LAST_QTIES'], 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_, 'sizechart' => $sizechart->sizechart, 'sizechart_data' => $sizechart->sizechart_data)); self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent'))); if ((int) Tools::getValue('pp') == 1) { $time4 = time(); echo 'time4: ' . $time4; } $images = $this->product->getImages((int) self::$cookie->id_lang); $productImages = array(); foreach ($images as $k => $image) { if ($image['cover']) { self::$smarty->assign('mainImage', $images[0]); $cover = $image; $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image']; $cover['id_image_only'] = (int) $image['id_image']; } $productImages[(int) $image['id_image']] = $image; } if (!isset($cover)) { $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture'); } $size = Image::getSize('large'); self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang))); if (sizeof($productImages)) { self::$smarty->assign('images', $productImages); } if ((int) Tools::getValue('pp') == 1) { $time5 = time(); echo 'time5: ' . $time5; } /* Attributes / Groups & colors */ $colors = array(); //see if the product has shades if ($this->product->id_group && $this->product->id_group > 0) { global $link; $related_productIds = $this->product->getRelatedProducts(); $related_products = array(); foreach ($related_productIds as &$productId) { $relProduct = new Product((int) $productId['id_product'], true, self::$cookie->id_lang); $idImage = $relProduct->getCoverWs(); if ($idImage) { $idImage = $relProduct->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $relProduct->image_link = $link->getImageLink($relProduct->link_rewrite, $idImage, 'small'); $relProduct->link = $relProduct->getLink(); $related_products[] = $relProduct; } self::$smarty->assign('relatedProducts', $related_products); } if ((int) Tools::getValue('pp') == 1) { $time6 = time(); echo 'time6: ' . $time6; } $attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang); // @todo (RM) should only get groups and not all declination ? if (is_array($attributesGroups) and $attributesGroups) { $groups = array(); $combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang); foreach ($attributesGroups as $k => $row) { /* Color management */ if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) { $colors[$row['id_attribute']]['value'] = $row['attribute_color']; $colors[$row['id_attribute']]['name'] = $row['attribute_name']; if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) { $colors[$row['id_attribute']]['attributes_quantity'] = 0; } $colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity']; } if (!isset($groups[$row['id_attribute_group']])) { $groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1); } $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name']; if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) { $groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute']; } if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) { $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0; } $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity']; $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name']; $combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute']; $combinations[$row['id_product_attribute']]['price'] = (double) $row['price']; $combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax']; $combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight']; $combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity']; $combinations[$row['id_product_attribute']]['reference'] = $row['reference']; $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact']; $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity']; $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1; } if ((int) Tools::getValue('pp') == 1) { $time7 = time(); echo 'time7: ' . $time7; } //wash attributes list (if some attributes are unavailables and if allowed to wash it) if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) { foreach ($groups as &$group) { foreach ($group['attributes_quantity'] as $key => &$quantity) { if (!$quantity) { unset($group['attributes'][$key]); } } } foreach ($colors as $key => $color) { if (!$color['attributes_quantity']) { unset($colors[$key]); } } } if ((int) Tools::getValue('pp') == 1) { $time71 = time(); echo 'time71: ' . $time71; } foreach ($groups as &$group) { natcasesort($group['attributes']); } foreach ($combinations as $id_product_attribute => $comb) { $attributeList = ''; foreach ($comb['attributes'] as $id_attribute) { $attributeList .= '\'' . (int) $id_attribute . '\','; } $attributeList = rtrim($attributeList, ','); $combinations[$id_product_attribute]['list'] = $attributeList; } self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages)); } if ((int) Tools::getValue('pp') == 1) { $time72 = time(); echo 'time72: ' . $time72; } //$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc'); /*$categoryProducts = $this->getRandomCatProducts(); self::$smarty->assign('cat_products', $categoryProducts);*/ //$brandProducts = $this->getRandomBrandProducts(); //self::$smarty->assign('brand_products', $brandProducts); if ((int) Tools::getValue('pp') == 1) { $time73 = time(); echo ' time73: ' . $time73; } self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang))); if ((int) Tools::getValue('pp') == 1) { $time74 = time(); echo 'time74: ' . $time74; } // Pack management self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array()); self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1)); if ((int) Tools::getValue('pp') == 1) { print_r('pack done'); } } } if ((int) Tools::getValue('pp') == 1) { $time8 = time(); echo 'time8: ' . $time8; } if ($this->is_saree || $this->is_lehenga) { if ($this->is_lehenga) { self::$smarty->assign('is_lehenga', $this->is_lehenga); } self::$smarty->assign('as_shown', (bool) $this->product->as_shown); /*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1)) self::$smarty->assign('measurement_info', $blouse_measurements); if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2)) self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/ if ((int) Tools::getValue('pp') == 1) { $time81 = time(); echo 'time81: ' . $time81; } if ($this->is_saree) { //count of all styles mapped to this product $res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1"); $style_count = (int) $res['style_count']; if ($style_count === 0) { // show the default style for sarees $style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round'); } else { $res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1"); if (!empty($res)) { //show the default style for this product $style = array('id_style' => $res['id_style'], 'style_image_small' => $res['style_image_small'], 'style_name' => $res['style_name']); } } if ((int) Tools::getValue('pp') == 1) { $time82 = time(); echo 'time82: ' . $time82; } self::$smarty->assign('blouse_style_count', $style_count); self::$smarty->assign('blouse_style', $style); } } else { if ($this->is_skd || $this->is_skd_rts) { self::$smarty->assign('is_anarkali', $this->is_anarkali); if ($this->is_anarkali) { if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 5)) { self::$smarty->assign('kurta_measurement_info', $kurta_measurements); } } else { if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 3)) { self::$smarty->assign('kurta_measurement_info', $kurta_measurements); } } if ($salwar_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 4)) { self::$smarty->assign('salwar_measurement_info', $salwar_measurements); } //get default styles for this product (RTS) if ($this->is_skd_rts) { $res = Db::getInstance()->ExecuteS("select count(s.id_style) as style_count, s.style_type, ps.id_product from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} group by ps.id_product,s.style_type"); foreach ($res as $s) { $style_count = (int) $s['style_count']; if ((int) $s['style_type'] === 4) { self::$smarty->assign('kurta_style_count', $style_count); } else { if ((int) $s['style_type'] === 5) { self::$smarty->assign('salwar_style_count', $style_count); } } } $res = Db::getInstance()->ExecuteS("select s.id_style, s.style_type, s.style_image_small, s.style_name from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and ps.is_default = 1"); foreach ($res as $s) { $style = array('id_style' => $s['id_style'], 'style_image_small' => $s['style_image_small'], 'style_name' => $s['style_name']); if ((int) $s['style_type'] === 4) { self::$smarty->assign('kurta_style', $style); } else { if ((int) $s['style_type'] === 5) { self::$smarty->assign('salwar_style', $style); } } } } } } self::$smarty->assign('is_bottoms', $this->is_bottoms); self::$smarty->assign('is_abaya', $this->is_abaya); self::$smarty->assign('is_wristwear', $this->is_wristwear); self::$smarty->assign('is_pakistani_rts', $this->is_pakistani_rts); if ((int) Tools::getValue('pp') == 1) { $time85 = time(); echo 'time85: ' . $time85; } self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => Product::getCover((int) Tools::getValue('id_product')), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'))); if ((int) Tools::getValue('pp') == 1) { $time9 = time(); echo 'time9: ' . $time9; } //add this to product stats //Tools::captureActivity(PSTAT_VIEWS,$id_product); if ((int) Tools::getValue('pp') == 1) { $time1 = time(); echo 'process end: ' . $time1; } }
private function getProductLink($product_id) { if (isset($this->context) && isset($this->context->link) && method_exists($this->context->link, 'getProductLink')) { return $this->context->link->getProductLink((int) $product_id); } global $link; if (isset($link) && method_exists($link, 'getProductLink')) { return $link->getProductLink((int) $product_id); } else { $full_product = new Product((int) $product_id, false); return $full_product->getLink(); } }
private function makeMenu() { global $cookie, $page_name; $curr_level = 1; foreach ($this->getMenuItems() as $key => $item) { extract($item); if ($depth > $curr_level) { $this->_menu .= '<ul>'; } if ($depth == $curr_level && $key != 0) { $this->_menu .= '</li>'; } if ($depth < $curr_level) { $this->_menu .= str_repeat('</li></ul>', $curr_level - $depth) . '</li>'; } $curr_level = $depth; switch ($type) { case 'CAT': $this->getCategory($id_ref, $cookie->id_lang); break; case 'PRD': $selected = $page_name == 'product' && Tools::getValue('id_product') == $id_ref ? ' class="sfHover"' : ''; $product = new Product($id_ref, true, $cookie->id_lang); if (!is_null($product->id)) { $this->_menu .= '<li' . $selected . '><a href="' . $product->getLink() . '"><span>' . $product->name . '</span></a>' . PHP_EOL; } break; case 'CCS': $selected = $page_name == 'cms' && Tools::getValue('id_cms_category') == $id_ref ? ' class="sfHover"' : ''; $_this_cat = new CMSCategory($id_ref, $cookie->id_lang); $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . $link->getCMSCategoryLink($_this_cat->id, $_this_cat->link_rewrite) . '"><span>' . htmlentities($_this_cat->name) . ' </span></a>' . PHP_EOL; break; case 'CMS': $selected = $page_name == 'cms' && Tools::getValue('id_cms') == $id_ref ? ' class="sfHover"' : ''; $cms = CMS::getLinks($cookie->id_lang, array($id_ref)); if (count($cms)) { $this->_menu .= '<li' . $selected . '><a href="' . $cms[0]['link'] . '"><span>' . htmlentities($cms[0]['meta_title']) . '</span></a>' . PHP_EOL; } break; case 'MAN': $selected = $page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id_ref ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer($id_ref, $cookie->id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . $link->getManufacturerLink($id_ref, $manufacturer->link_rewrite) . '">' . $manufacturer->name . '</a>' . PHP_EOL; } break; case 'SUP': $selected = $page_name == 'supplier' && Tools::getValue('id_supplier') == $id_ref ? ' class="sfHover"' : ''; $supplier = new Supplier($id_ref, $cookie->id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . $link->getSupplierLink($id_ref, $supplier->link_rewrite) . '"><span>' . $supplier->name . '</span></a>' . PHP_EOL; } break; case 'LNK': $link = WPMenuTopLinks::get($id_ref, $cookie->id_lang); if (count($link)) { $this->_menu .= '<li><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</span></a>' . PHP_EOL; } break; } } $this->_menu .= str_repeat('</li></ul>', $curr_level - 1) . '</li>'; }
private function _getCSVFileText() { $link = new Link(); $schema = ''; $schema .= $this->quoting . $this->_idealocsv->l('id', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('brand', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('title', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('Category', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('Short Description', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('description', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('image_link', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('link', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('price', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('ean', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('availability', 'idealo') . $this->quoting . $this->fieldseparator; foreach ($this->shipping as $ship) { if ($ship['active'] == '1') { foreach ($this->payment as $pay) { if ($pay['active'] == '1') { $schema .= $this->quoting . strtoupper($pay['db']) . '_' . $ship['country'] . $this->quoting . $this->fieldseparator; } } } } foreach ($this->shipping as $ship) { if ($ship['active'] == '1') { $schema .= $this->quoting . $this->_idealocsv->l('shipping', 'idealo') . '_' . $ship['country'] . $this->quoting . $this->fieldseparator; } } $schema .= $this->quoting . $this->_idealocsv->l('shipping_weight', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('baseprice', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('EAN', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . $this->_idealocsv->l('condition', 'idealo') . $this->quoting . $this->fieldseparator . $this->quoting . 'portocomment' . $this->quoting . $this->fieldseparator; if ($this->minOrderPrice != '') { $schema .= $this->quoting . $this->_idealocsv->l('Small order value surcharge', 'idealo') . $this->quoting . $this->fieldseparator; } $schema .= $this->quoting . 'Attributes' . $this->quoting . $this->fieldseparator; $schema .= "\n"; setlocale(LC_ALL, 'de_DE'); $date = date("d.m.y H:i:s"); $schema .= $this->quoting . sprintf($this->_idealocsv->l('Last file created on %s o\'clock', 'idealo'), $date) . $this->quoting . $this->fieldseparator; $schema .= "\n"; $schema .= sprintf($this->_idealocsv->l('idealo - CSV export-modul V %s for PrestaShop from %s', 'idealo'), IDEALO_MODULE_VERSION, IDEALO_MODULE_DATE); $schema .= "\n"; $article = $this->getArticleNumbers(); foreach ($article as $a) { $product = new Product($a['id_product'], false, $this->id_lang); $productlink = $product->getLink(); if ($this->campaign == '1') { $productlink .= CAMPAIGN; } $cat = $product->getProductCategoriesFull($a['id_product'], $this->id_lang); $brand = $this->getBrand($product->id_manufacturer); $cat_text = $this->getCatText($cat); if ($this->checkFilter($cat_text, $brand, $a['id_product']) === true) { $images = $product->getCover($a['id_product']); $imagelink = $link->getImageLink($product->link_rewrite[1], $product->id . '-' . $images['id_image'], ''); $price = number_format($product->getprice(), 2, '.', ''); $attributeCombinations = $product->getAttributeCombinaisons($this->id_lang); if (!empty($attributeCombinations)) { $attributeCombinations = $this->sortAttributeCombinations($attributeCombinations); $taxRate = $this->getTaxRate($product->id_tax_rules_group); $i = 1; foreach ($attributeCombinations as $combination) { if ($combination[0]['quantity'] > 0) { $image = ''; $image_id = $this->getImegeLinkOfAtrribute($combination[0]['id_product_attribute']); if ($image_id == 0) { $image = $imagelink; } else { $image = new Image($image_id); $image = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image->getExistingImgPath() . '.jpg'; } $articleId = $a['id_product'] . '_' . $i; $combinationString = $this->getCombinationString($combination); $title = $product->name . ' ' . str_replace(';', ',', $combinationString); $combinationPrice = $price + number_format($combination[0]['price'] * (1 + $taxRate / 100), 2, '.', ''); $weight = $product->weight + $combination[0]['weight']; $combinationEan = $combination[0]['ean13']; $schema .= $this->getProductLine($product, $articleId, $brand, $title, $cat_text, $image, $productlink, $combinationPrice, $weight, $combinationString, ${$combinationEan}); } $i++; if ($i >= 100) { break; } } } else { $schema .= $this->getProductLine($product, $a['id_product'], $brand, $product->name, $cat_text, $imagelink, $productlink, $price, $product->weight); } } } return $schema; }
/** * @param Solarium_Query_Update $update * @param Link $link * @param Product $productObj * @return Solarium_Document_ReadWrite */ private static function getProductDoc($update, $link, $productObj) { $doc = $update->createDocument(); $doc->id_product = $productObj->id; $doc->reference = $productObj->reference; $doc->name = $productObj->name; //$doc->description = $productObj->description; $doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description); $doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->brand_id = $productObj->id_manufacturer; $doc->brand_name = $productObj->manufacturer_name; $doc->style_tips = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->alphaNameSort = $productObj->name; $dbresult = $productObj->getWsCategories(); $catIds = array(); foreach ($dbresult as $catIdRow) { $catIds[] = $catIdRow['id']; } $category_names = array(); foreach ($catIds as $catID) { $category = new Category((int) $catID); $category_names[] = $category->getName(1); } $doc->cat_name = $category_names; $doc->cat_id = $catIds; $doc->tags = $productObj->getTags(1); $doc->shipping_sla = $productObj->shipping_sla; $doc->weight = $productObj->weight ? $productObj->weight : 0.5; $doc->cashback_percentage = $productObj->cashback_percentage; if (isset($productObj->work_type)) { $doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : ''); } if (isset($productObj->garment_type)) { $doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : ''); } if (isset($productObj->blouse_length)) { $doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : ''; } $doc->height = $productObj->height; $doc->width = $productObj->width; $atributeQty = Attribute::getAttributeQty($productObj->id); if ($productObj->quantity > 0 || $atributeQty > 0) { $doc->inStock = true; } else { $doc->inStock = false; } $doc->isPlusSize = $productObj->is_plussize ? true : false; $doc->isRTS = $productObj->is_rts ? true : false; $doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0); $date = DateTime::createFromFormat('Y-m-d H:i:s', $productObj->date_add); $doc->date_add = $date->format("Y-m-d\\TG:i:s\\Z"); $productObj->fabric = trim($productObj->fabric); $productObj->fabric = preg_replace('/\\s+/', '-', $productObj->fabric); $doc->fabric = strtolower($productObj->fabric); $doc->is_customizable = $productObj->is_customizable; if (isset($productObj->generic_color) && !empty($productObj->generic_color)) { $colors = explode(',', $productObj->generic_color); $indexed_colors = array(); foreach ($colors as $color) { $indexed_colors[] = strtolower(preg_replace('/\\s+/', '-', trim($color))); } $doc->color = $indexed_colors; } if (isset($productObj->stone) && !empty($productObj->stone)) { $stones = explode(',', $productObj->stone); $indexed_stones = array(); foreach ($stones as $stone) { $indexed_stones[] = strtolower(preg_replace('/\\s+/', '-', trim($stone))); } $doc->stone = $indexed_stones; } if (isset($productObj->plating) && !empty($productObj->plating)) { $platings = explode(',', $productObj->plating); $indexed_platings = array(); foreach ($platings as $plating) { $indexed_platings[] = strtolower(preg_replace('/\\s+/', '-', trim($plating))); } $doc->plating = $indexed_platings; } if (isset($productObj->material) && !empty($productObj->material)) { $materials = explode(',', $productObj->material); $indexed_materials = array(); foreach ($materials as $material) { $indexed_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($material))); } $doc->material = $indexed_materials; } if (isset($productObj->look) && !empty($productObj->look)) { $looks = explode(',', $productObj->look); $indexed_looks = array(); foreach ($looks as $look) { $indexed_looks[] = strtolower(preg_replace('/\\s+/', '-', trim($look))); } $doc->look = $indexed_looks; } if (isset($productObj->handbag_occasion) && !empty($productObj->handbag_occasion)) { $handbag_occasions = explode(',', $productObj->handbag_occasion); $indexed_handbag_occasions = array(); foreach ($handbag_occasions as $handbag_occasion) { $indexed_handbag_occasions[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_occasion))); } $doc->handbag_occasion = $indexed_handbag_occasions; } if (isset($productObj->handbag_style) && !empty($productObj->handbag_style)) { $handbag_styles = explode(',', $productObj->handbag_style); $indexed_handbag_styles = array(); foreach ($handbag_styles as $handbag_style) { $indexed_handbag_styles[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_style))); } $doc->handbag_style = $indexed_handbag_styles; } if (isset($productObj->handbag_material) && !empty($productObj->handbag_material)) { $handbag_materials = explode(',', $productObj->handbag_material); $indexed_handbag_materials = array(); foreach ($handbag_materials as $handbag_material) { $indexed_handbag_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_material))); } $doc->handbag_material = $indexed_handbag_materials; } $combinaisons = $productObj->getAttributeCombinaisons(1); $indexed_sizes = array(); foreach ($combinaisons as $k => $combinaison) { if ($combinaison['group_name'] == 'size' || $combinaison['group_name'] == 'Size') { $indexed_sizes[] = $combinaison['attribute_name']; } } $doc->size = $indexed_sizes; //Indian Price $doc->offer_price_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, true, 1, false, NULL, NULL, IND_ADDRESS_ID); $doc->offer_price_in_rs = Tools::convertPrice($doc->offer_price_in, 4); $doc->mrp_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, false, 1, false, NULL, NULL, IND_ADDRESS_ID); if ($doc->mrp_in > $doc->offer_price_in) { $doc->discount_in = Tools::ps_round(($doc->mrp_in - $doc->offer_price_in) / $doc->mrp_in * 100); } //Worldwide Price $doc->offer_price = $productObj->getPrice(); $doc->offer_price_rs = Tools::convertPrice($doc->offer_price, 4); $doc->mrp = $productObj->getPriceWithoutReduct(); if ($doc->mrp > $doc->offer_price) { $doc->discount = Tools::ps_round(($doc->mrp - $doc->offer_price) / $doc->mrp * 100); } $doc->product_link = $productObj->getLink(); $idImage = $productObj->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $doc->image_link_list = $link->getImageLink($productObj->link_rewrite, $idImage, 'list'); $doc->image_link_medium = $link->getImageLink($productObj->link_rewrite, $idImage, 'medium'); $doc->image_link_large = $link->getImageLink($productObj->link_rewrite, $idImage, 'large'); $images = $productObj->getImages(1); $productImages = array(); foreach ($images as $k => $image) { $productImages[] = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'large'); } $doc->image_links = $productImages; return $doc; }
public function getMenuCustomerLink($lang_id = NULL) { $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menuLink .= $this->drawCustomMenuItem($id, 0, false, 0, $lang_id); break; case 'PRD': $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : ''; $product = new Product((int) $id, true, (int) $id_lang); if (!is_null($product->id)) { $this->_menuLink .= '<div id ="pt_menu_product" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '"><span>' . $product->name . '</span></a></div></div>' . PHP_EOL; } break; case 'CMS': $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : ''; $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '"><span>' . $cms[0]['meta_title'] . '</span></a></div></div>' . PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int) $id, (int) $id_lang); if (Validate::isLoadedObject($category)) { $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '"><span>' . $category->name . '</span></a>'; } $this->_menuLink .= '</div>' . PHP_EOL; $this->_menuLink .= $this->getCMSMenuItems($category->id); // Case to handle the option to show all Manufacturers // Case to handle the option to show all Manufacturers case 'ALLMAN': $link = new Link(); $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('manufacturer') . '" ><span>' . $this->l('All manufacturers') . '</span></a></div>' . PHP_EOL; $manufacturers = Manufacturer::getManufacturers(); $this->_menuLink .= '<div class ="popup" style ="display:none">'; foreach ($manufacturers as $key => $manufacturer) { $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '">' . $manufacturer['name'] . '</a></div></div></div>' . PHP_EOL; } $this->_menuLink .= '</div></div>'; break; case 'MAN': $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int) $id, (int) $id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_menuLink .= '<div id ="pt_menu_man" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '"><span>' . $manufacturer->name . '</span></a></div></div>' . PHP_EOL; } break; // Case to handle the option to show all Suppliers // Case to handle the option to show all Suppliers case 'ALLSUP': $link = new Link(); $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('supplier') . '" ><span>' . $this->l('All suppliers') . '</span></a></div>' . PHP_EOL; $suppliers = Supplier::getSuppliers(); $this->_menuLink .= '<div class ="popup" style ="display:none">'; foreach ($suppliers as $key => $supplier) { $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '">' . $supplier['name'] . '</a></div></div></div>' . PHP_EOL; } $this->_menuLink .= '</div></div>'; break; case 'SUP': $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : ''; $supplier = new Supplier((int) $id, (int) $id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL; } break; case 'SHOP': $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : ''; $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $link = new Link(); $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL; } break; case 'LNK': $link = VegaTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop); if (count($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = VegaTopLinks::get($link[0]['id_linksvegatop'], $default_language, (int) Shop::getContextShopID()); } $this->_menuLink .= '<div id ="pt_ver_menu_link" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</a></span></div></div>' . PHP_EOL; } break; } } }
/** * Execute hook * * @param mixed $params */ public function hookOrderConfirmation($params) { global $smarty, $cookie, $link; if (!$this->active) { return; } // seting error handler eval('function itembaseErrorHandler($errno, $errstr, $errfile, $errline) { ' . ((bool) Configuration::get('PS_ITEMBASE_DEBUG') ? 'echo " <!--ITEMBASE ".print_r(array($errno, $errstr, $errfile, $errline), true)."ITEMBASE--> ";' : '') . ' return true; }'); set_error_handler('itembaseErrorHandler', E_ALL); try { include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/plugindata.php'; include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/oauth.php'; // geting access token $responseArray = $this->jsonDecode(authenticateClient(Configuration::get('PS_ITEMBASE_APIKEY'), Configuration::get('PS_ITEMBASE_SECRET'))); if (!isset($responseArray['access_token'])) { itembaseErrorHandler(0, 'no access_token for ' . Tools::safeOutput(Configuration::get('PS_ITEMBASE_APIKEY')) . ' ' . substr(Tools::safeOutput(Configuration::get('PS_ITEMBASE_SECRET')), 0, 4) . '... ' . PS_ITEMBASE_SERVER_OAUTH . ' ' . print_r($responseArray, true), __FILE__, __LINE__ - 1); } // order data gathering $order = new Order($params['objOrder']->id, NULL); $currency = Currency::getCurrency((int) $order->id_currency); $carrier = new Carrier((int) $order->id_carrier); $language = Language::getLanguage((int) $cookie->id_lang); $customer = new Customer((int) $order->id_customer); $address = $customer->getAddresses($cookie->id_lang); if (is_object($address)) { $address = (array) $address; } if (isset($address['0'])) { $address = $address['0']; } // products data gathering $allProducts = array(); foreach ($order->getProductsDetail() as $order_detail) { $product_id = $order_detail['product_id']; $product = new Product($product_id, true, null); $cover = Product::getCover($product_id); $product_img = $link->getImageLink($product->link_rewrite, $product_id . '-' . $cover['id_image']); if (strpos($product_img, 'http') !== 0) { $product_img = Tools::getHttpHost(true) . $product_img; } $category = new Category($product->id_category_default); $allProducts[] = array('id' => $order_detail['product_id'], 'category' => $category->name, 'name' => $product->name, 'quantity' => $order_detail['product_quantity'], 'price' => $product->getPrice(true, NULL, 2), 'ean' => $product->ean13, 'isbn' => '', 'asin' => '', 'description' => $product->description_short, 'pic_thumb' => $product_img, 'pic_medium' => $product_img, 'pic_large' => $product_img, 'url' => $product->getLink(), 'presta_lang_id' => $language['id_lang']); } $dataForItembase = array('access_token' => $responseArray['access_token'], 'email' => $customer->email, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'street' => $address['address1'] . ($address['address2'] ? ' ' . $address['address2'] : ''), 'zip' => $address['postcode'], 'city' => $address['city'], 'country' => $address['country'], 'phone' => $address['phone'], 'lang' => $language['iso_code'], 'purchase_date' => $order->date_add, 'currency' => $currency['iso_code'], 'total' => $order->total_products_wt, 'order_number' => $order->id, 'customer_id' => $order->id_customer, 'invoice_number' => $order->invoice_number, 'shipping_cost' => $order->total_shipping, 'carrier' => $carrier->name, 'payment_option' => $order->payment, 'is_opt_in' => $customer->newsletter, 'shop_name' => class_exists('Context', false) ? Context::getContext()->shop->name : Configuration::get('PS_SHOP_NAME'), 'products' => $allProducts); // encoding data utf8EncodeRecursive($dataForItembase); $smarty->assign('ibdata', $dataForItembase); $smarty->assign('ibdatajson', $this->jsonEncode($dataForItembase)); $smarty->assign('ibembedserver', PS_ITEMBASE_SERVER_EMBED); $smarty->assign('ibhostserver', PS_ITEMBASE_SERVER_HOST); $smarty->assign('ibpluginversion', PS_ITEMBASE_PLUGIN_VERSION); $smarty->assign('ibtop', Configuration::get('PS_ITEMBASE_TOP')); } catch (Exception $e) { itembaseErrorHandler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } // restoring error handler restore_error_handler(); return $this->display(__FILE__, 'views/templates/front/checkout_plugin.tpl'); }
} elseif (in_array(CAT_CHOLIS, $catIds)) { $category = 'Choli'; } elseif (in_array(CAT_GIFTCARD, $catIds)) { $category = 'GiftCard'; } elseif (in_array(CAT_JEWELRY, $catIds)) { $category = 'Jewelry'; } elseif (in_array(CAT_KIDS, $catIds)) { $category = 'Kids'; } elseif (in_array(CAT_ABAYA, $catIds)) { $category = 'Abaya'; } elseif (in_array(CAT_MEN, $catIds)) { $category = 'Men'; } elseif (in_array(CAT_HANDBAG, $catIds)) { $category = 'Handbag'; } $doc->product_link = $productObj->getLink(); $idImage = $productObj->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $thickbox_image = $link->getImageLink($productObj->link_rewrite, $idImage, 'thickbox'); $large_image = $link->getImageLink($productObj->link_rewrite, $idImage, 'large'); $id_manufacturer = $productObj->id_manufacturer; $manufacturer = ''; if (!empty($id_manufacturer)) { $manufacturer = Manufacturer::getNameById($id_manufacturer); } $productRec = array($id_product, $productObj->reference, $productObj->supplier_reference, $productObj->name, $productObj->getLink(), $productObj->getPriceWithoutReduct(), round($productObj->getPrice()), round($mrp_in_rs), round($offer_price_in_rs), strip_tags($productObj->description), '0', $availability, $manufacturer, $category, $categories, $color, $fabric, (int) $productObj->active === 1 ? 'ACTIVE' : 'INACTIVE', $quantity, $productObj->shipping_sla, $productObj->is_customizable, $large_image, $thickbox_image, date('Y-m-d', strtotime($productObj->date_add))); $images = $productObj->getImages(1);
private function makeMenu() { global $cookie, $page_name; foreach ($this->getMenuItems() as $item) { $id = (int) substr($item, 3, strlen($item)); switch (substr($item, 0, 3)) { case 'CAT': $this->getCategory($id, $cookie->id_lang); break; case 'PRD': $selected = $page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : ''; $product = new Product($id, true, $cookie->id_lang); if (!is_null($product->id)) { $this->_menu .= '<li' . $selected . '><a href="' . $product->getLink() . '">' . $product->name . '</a></li>' . PHP_EOL; } break; case 'CMS': $selected = $page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : ''; $cms = CMS::getLinks($cookie->id_lang, array($id)); if (count($cms)) { $this->_menu .= '<li' . $selected . '><a href="' . $cms[0]['link'] . '">' . $cms[0]['meta_title'] . '</a></li>' . PHP_EOL; } break; case 'MAN': $selected = $page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer($id, $cookie->id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . $link->getManufacturerLink($id, $manufacturer->link_rewrite) . '">' . $manufacturer->name . '</a></li>' . PHP_EOL; } break; case 'SUP': $selected = $page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : ''; $supplier = new Supplier($id, $cookie->id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . $link->getSupplierLink($id, $supplier->link_rewrite) . '">' . $supplier->name . '</a></li>' . PHP_EOL; } break; case 'LNK': $link = MenuTopLinks::get($id, $cookie->id_lang); if (count($link)) { $this->_menu .= '<li><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '>' . $link[0]['label'] . '</a></li>' . PHP_EOL; } break; } } }
function addProducts($client, $ids = array()) { //update currency // update_currency(); $default_tz = date_default_timezone_get(); date_default_timezone_set('UTC'); $category = new Category(1, 1); $sql = "select p.id_product, DATEDIFF(NOW(), p.`date_add`) as 'age'\n from ps_product p\n where p.price > 0 and p.active = 1"; $productScores = array(); $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($products as $product) { $productScores[$product['id_product']] = array('age' => $product['age'], 'week_sold' => 0, 'month_sales' => 0, 'year_sales' => 0); } $sql = "select p.`id_product`, sum(od.product_quantity) as 'quantity'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 \n and p.active = 1\n and o.date_add > now() - INTERVAL 7 DAY\n group by p.id_product"; $week_quantities = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($week_quantities as $week_quantity) { $productScores[$week_quantity['id_product']]['week_sold'] = $week_quantity['quantity']; } $sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'month_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 30 DAY\n group by p.id_product"; $month_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($month_sales as $month_sale) { $productScores[$month_sale['id_product']]['month_sales'] = $month_sale['month_revenue']; } $sql = "select p.`id_product`, round(sum(od.product_quantity * od.product_price * 55 / o.`conversion_rate`)) as 'year_revenue'\n from `ps_product` p\n inner join `ps_order_detail` od on od.product_id = p.id_product\n inner join ps_orders o on o.id_order = od.id_order\n where p.price > 0 and p.active = 1\n and o.date_add > now() - INTERVAL 365 DAY\n group by p.id_product"; $year_sales = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($year_sales as $year_sale) { $productScores[$year_sale['id_product']]['year_sales'] = $year_sale['year_revenue']; } foreach ($products as $product) { $productScores[$product['id_product']]['score'] = getWeekSalesScore($productScores[$product['id_product']]['week_sold']) + getAgeScore($productScores[$product['id_product']]['age']) + getMonthScore($productScores[$product['id_product']]['month_sales']) + getYearScore($productScores[$product['id_product']]['year_sales']); } $docs = array(); $link = new Link(); $count = 0; $update = $client->createUpdate(); foreach ($products as $product) { if (!empty($ids) && !in_array((int) $product['id_product'], $ids)) { continue; } $productObj = new Product((int) $product['id_product'], true, 1); print_r('\\n' . 'reindexing ' . $product['id_product']); if (!$productObj->active) { deleteProduct($productObj->id, $client); continue; } $doc = $update->createDocument(); $doc->id_product = $productObj->id; $doc->reference = $productObj->reference; $doc->name = $productObj->name; $doc->description = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description); $doc->description_short = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->description_short); $doc->brand_id = $productObj->id_manufacturer; $doc->brand_name = $productObj->manufacturer_name; $doc->style_tips = $productObj->description_short; $doc->alphaNameSort = $productObj->name; $dbresult = $productObj->getWsCategories(); $catIds = array(); foreach ($dbresult as $catIdRow) { $catIds[] = $catIdRow['id']; } $category_names = array(); foreach ($catIds as $catID) { $category = new Category((int) $catID); $category_names[] = $category->getName(1); } $doc->cat_name = $category_names; $doc->cat_id = $catIds; $doc->tags = $productObj->getTags(1); $doc->shipping_sla = $productObj->shipping_sla ? $productObj->shipping_sla : 0; $doc->weight = $productObj->weight ? $productObj->weight : 0.5; if (isset($productObj->work_type)) { $doc->work_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->work_type ? $productObj->work_type : ''); } if (isset($productObj->garment_type)) { $doc->garment_type = preg_replace('@[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]@', ' ', $productObj->garment_type ? $productObj->garment_type : ''); } if (isset($productObj->blouse_length)) { $doc->blouse_length = $productObj->blouse_length ? $productObj->blouse_length : ''; } $doc->height = $productObj->height; $doc->width = $productObj->width; $atributeQty = Attribute::getAttributeQty($productObj->id); if ($productObj->quantity > 0 || $atributeQty > 0) { $doc->inStock = true; } else { $doc->inStock = false; } $doc->isPlusSize = $productObj->is_plussize ? true : false; $doc->isRTS = $productObj->is_rts ? true : false; $doc->quantity = $productObj->quantity ? $productObj->quantity : ($atributeQty ? $atributeQty : 0); //Indian Price $doc->offer_price_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, true, 1, false, NULL, NULL, IND_ADDRESS_ID); $doc->offer_price_in_rs = Tools::convertPrice($doc->offer_price_in, 4); $doc->mrp_in = Product::getPriceStatic($productObj->id, true, NULL, 6, NULL, false, false, 1, false, NULL, NULL, IND_ADDRESS_ID); if ($doc->mrp_in > $doc->offer_price_in) { $doc->discount_in = Tools::ps_round(($doc->mrp_in - $doc->offer_price_in) / $doc->mrp_in * 100); } //Worldwide Price $doc->offer_price = $productObj->getPrice(); $doc->offer_price_rs = Tools::convertPrice($doc->offer_price, 4); $doc->mrp = $productObj->getPriceWithoutReduct(); if ($doc->mrp > $doc->offer_price) { $doc->discount = Tools::ps_round(($doc->mrp - $doc->offer_price) / $doc->mrp * 100); } $date = DateTime::createFromFormat('Y-m-d H:i:s', $productObj->date_add); $doc->date_add = $date->format("Y-m-d\\TG:i:s\\Z"); $doc->product_link = $productObj->getLink(); $idImage = $productObj->getCoverWs(); if ($idImage) { $idImage = $productObj->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $doc->image_link_list = $link->getImageLink($productObj->link_rewrite, $idImage, 'list'); $doc->image_link_medium = $link->getImageLink($productObj->link_rewrite, $idImage, 'medium'); $doc->image_link_large = $link->getImageLink($productObj->link_rewrite, $idImage, 'large'); $images = $productObj->getImages(1); $productImages = array(); foreach ($images as $k => $image) { $productImages[] = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'large'); } $doc->image_links = $productImages; $doc->sales = $productScores[$product['id_product']]['score']; $productObj->fabric = trim($productObj->fabric); $productObj->fabric = preg_replace('/\\s+/', '-', $productObj->fabric); $doc->fabric = strtolower($productObj->fabric); $doc->is_customizable = $productObj->is_customizable; if (isset($productObj->generic_color) && !empty($productObj->generic_color)) { $colors = explode(',', $productObj->generic_color); $indexed_colors = array(); foreach ($colors as $color) { $indexed_colors[] = strtolower(preg_replace('/\\s+/', '-', trim($color))); } $doc->color = $indexed_colors; } if (isset($productObj->stone) && !empty($productObj->stone)) { $stones = explode(',', $productObj->stone); $indexed_stones = array(); foreach ($stones as $stone) { $indexed_stones[] = strtolower(preg_replace('/\\s+/', '-', trim($stone))); } $doc->stone = $indexed_stones; } if (isset($productObj->plating) && !empty($productObj->plating)) { $platings = explode(',', $productObj->plating); $indexed_platings = array(); foreach ($platings as $plating) { $indexed_platings[] = strtolower(preg_replace('/\\s+/', '-', trim($plating))); } $doc->plating = $indexed_platings; } if (isset($productObj->material) && !empty($productObj->material)) { $materials = explode(',', $productObj->material); $indexed_materials = array(); foreach ($materials as $material) { $indexed_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($material))); } $doc->material = $indexed_materials; } if (isset($productObj->look) && !empty($productObj->look)) { $looks = explode(',', $productObj->look); $indexed_looks = array(); foreach ($looks as $look) { $indexed_looks[] = strtolower(preg_replace('/\\s+/', '-', trim($look))); } $doc->look = $indexed_looks; } if (isset($productObj->handbag_occasion) && !empty($productObj->handbag_occasion)) { $handbag_occasions = explode(',', $productObj->handbag_occasion); $indexed_handbag_occasions = array(); foreach ($handbag_occasions as $handbag_occasion) { $indexed_handbag_occasions[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_occasion))); } $doc->handbag_occasion = $indexed_handbag_occasions; } if (isset($productObj->handbag_style) && !empty($productObj->handbag_style)) { $handbag_styles = explode(',', $productObj->handbag_style); $indexed_handbag_styles = array(); foreach ($handbag_styles as $handbag_style) { $indexed_handbag_styles[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_style))); } $doc->handbag_style = $indexed_handbag_styles; } if (isset($productObj->handbag_material) && !empty($productObj->handbag_material)) { $handbag_materials = explode(',', $productObj->handbag_material); $indexed_handbag_materials = array(); foreach ($handbag_materials as $handbag_material) { $indexed_handbag_materials[] = strtolower(preg_replace('/\\s+/', '-', trim($handbag_material))); } $doc->handbag_material = $indexed_handbag_materials; } $combinaisons = $productObj->getAttributeCombinaisons(1); $indexed_sizes = array(); foreach ($combinaisons as $k => $combinaison) { if ($combinaison['group_name'] == 'size' || $combinaison['group_name'] == 'Size') { $indexed_sizes[] = $combinaison['attribute_name']; } } $doc->size = $indexed_sizes; $doc->cashback_percentage = $productObj->cashback_percentage; $docs[] = $doc; if (++$count == 300) { $update->addDocuments($docs); $result = $client->update($update); echo 'Update query executed' . PHP_EOL; echo 'Query status: ' . $result->getStatus() . PHP_EOL; echo 'Query time: ' . $result->getQueryTime() . PHP_EOL; $count = 0; $docs = array(); $update = $client->createUpdate(); } } $update->addDocuments($docs); date_default_timezone_set($default_tz); $result = $client->update($update); $sql = "update ps_product set indexed = 1 where indexed = 0"; Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); }
private function makeMenu() { $menu = ''; $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); $head = $this->_itemHead; $tail = $this->_itemTail; foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->getCategory($menu, (int) $id); break; case 'PRD': $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' active' : ''; $product = new Product((int) $id, true, (int) $id_lang); if (!is_null($product->id)) { $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $product->getLink() . '"><span>' . $product->name . '</span></a></li>' . $tail . PHP_EOL; } break; case 'CMS': $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' active' : ''; $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $cms[0]['link'] . '"><span>' . $cms[0]['meta_title'] . '</span></a></li>' . $tail . PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int) $id, (int) $id_lang); if (count($category)) { $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $category->getLink() . '"><span>' . $category->name . '</span></a>'; $this->getCMSMenuItems($menu, $category->id); $menu .= '</li>' . $tail . PHP_EOL; } break; case 'MAN': $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' active' : ''; $manufacturer = new Manufacturer((int) $id, (int) $id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getManufacturerLink((int) $id, $manufacturer->link_rewrite) . '"><span>' . $manufacturer->name . '</span></a></li>' . $tail . PHP_EOL; } break; case 'SUP': $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' active' : ''; $supplier = new Supplier((int) $id, (int) $id_lang); if (!is_null($supplier->id)) { $link = new Link(); $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getSupplierLink((int) $id, $supplier->link_rewrite) . '"><span>' . $supplier->name . '</span></a></li>' . $tail . PHP_EOL; } break; case 'SHOP': $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' active' : ''; $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $link = new Link(); $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $shop->getBaseURL() . '"><span>' . $shop->name . '</span></a></li>' . $tail . PHP_EOL; } break; case 'LNK': $link = MenuTopLinks_mod::get((int) $id, (int) $id_lang, (int) $id_shop); if (count($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks_mod::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); } $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</span></a></li>' . $tail . PHP_EOL; } break; } } return $menu; }
public function process() { parent::process(); self::$smarty->assign(array('is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int) $this->id_order), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int) $this->id_order, (int) $this->id_module))); if (self::$cookie->is_guest) { self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order))); /* If guest we clear the cookie for security reason */ self::$cookie->logout(); } else { self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order))); } //assign order details here $order = new Order($this->id_order); if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) { $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); // $stateInvoiceAddress = new State((int)$addressInvoice->id_state); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts)); } self::$smarty->assign('order_total', Tools::ps_round($order->total_paid)); self::$smarty->assign('order_total_usd', Tools::ps_round(Tools::convertPrice($order->total_paid, self::$cookie->id_currency, false))); $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); $customer = new Customer($order->id_customer); $order->customization_fee = Cart::getCustomizationCostStatic((int) $order->id_cart); $totalQuantity = 0; foreach ($products as $productRow) { $totalQuantity += $productRow['product_quantity']; } if (strpos($order->payment, 'COD') === false) { self::$smarty->assign('paymentMethod', 'ONLINE'); } else { self::$smarty->assign('paymentMethod', 'COD'); } $shippingdate = new DateTime($order->expected_shipping_date); self::$smarty->assign(array('shipping_date' => $shippingdate->format("F j, Y"), 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => Message::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'totalQuantity' => $totalQuantity)); if ($carrier->url and $order->shipping_number) { self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); //FB Share //$products = $order->getProducts(); $orderProducts = array(); $productMaxVal = 0; $productMaxId = null; foreach ($products as $product) { array_push($orderProducts, $product['product_id']); if ($product['product_price'] > $productMaxVal) { $productMaxId = $product['product_id']; $productMaxVal = $product['product_price']; } } $productObj = new Product($productMaxId, true, 1); self::$smarty->assign('fbShareProductObject', $productObj->getLink()); self::$smarty->assign('fbShareProductObjectId', $productMaxId); self::$smarty->assign('orderProducts', implode(",", $orderProducts)); self::$cookie->shareProductCode = md5(time() . $productMaxId); self::$cookie->write(); unset($carrier); unset($addressInvoice); unset($addressDelivery); } }
protected function makeMenu() { $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups)); break; case 'PRD': $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : ''; $product = new Product((int) $id, true, (int) $id_lang); if (!is_null($product->id)) { $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '" title="' . $product->name . '">' . $product->name . '</a></li>' . PHP_EOL; } break; case 'CMS': $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : ''; $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '" title="' . Tools::safeOutput($cms[0]['meta_title']) . '">' . Tools::safeOutput($cms[0]['meta_title']) . '</a></li>' . PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int) $id, (int) $id_lang); if (count($category)) { $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '" title="' . $category->name . '">' . $category->name . '</a>'; $this->getCMSMenuItems($category->id); $this->_menu .= '</li>' . PHP_EOL; } break; // Case to handle the option to show all Manufacturers // Case to handle the option to show all Manufacturers case 'ALLMAN': $link = new Link(); $this->_menu .= '<li><a href="' . $link->getPageLink('manufacturer') . '" title="' . $this->l('All manufacturers') . '">' . $this->l('All manufacturers') . '</a><ul>' . PHP_EOL; $manufacturers = Manufacturer::getManufacturers(); foreach ($manufacturers as $key => $manufacturer) { $this->_menu .= '<li><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '" title="' . Tools::safeOutput($manufacturer['name']) . '">' . Tools::safeOutput($manufacturer['name']) . '</a></li>' . PHP_EOL; } $this->_menu .= '</ul>'; break; case 'MAN': $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int) $id, (int) $id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '" title="' . Tools::safeOutput($manufacturer->name) . '">' . Tools::safeOutput($manufacturer->name) . '</a></li>' . PHP_EOL; } break; // Case to handle the option to show all Suppliers // Case to handle the option to show all Suppliers case 'ALLSUP': $link = new Link(); $this->_menu .= '<li><a href="' . $link->getPageLink('supplier') . '" title="' . $this->l('All suppliers') . '">' . $this->l('All suppliers') . '</a><ul>' . PHP_EOL; $suppliers = Supplier::getSuppliers(); foreach ($suppliers as $key => $supplier) { $this->_menu .= '<li><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '" title="' . Tools::safeOutput($supplier['name']) . '">' . Tools::safeOutput($supplier['name']) . '</a></li>' . PHP_EOL; } $this->_menu .= '</ul>'; break; case 'SUP': $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : ''; $supplier = new Supplier((int) $id, (int) $id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '" title="' . $supplier->name . '">' . $supplier->name . '</a></li>' . PHP_EOL; } break; case 'SHOP': $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : ''; $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '" title="' . $shop->name . '">' . $shop->name . '</a></li>' . PHP_EOL; } break; case 'LNK': $link = MenuTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop); if (count($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); } $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' onclick="return !window.open(this.href);"' : '') . ' title="' . Tools::safeOutput($link[0]['label']) . '">' . Tools::safeOutput($link[0]['label']) . '</a></li>' . PHP_EOL; } break; } } }
private function makeMegaDrown() { $IdLang = $this->context->cookie->id_lang; if (Tools::getIsset('id_category')) { $ActiveCategory = (int) Tools::getValue('id_category'); } else { $ActiveCategory = null; } if (Tools::getIsset('id_product')) { if (!isset($this->context->cookie->last_visited_category) or !Product::idIsOnCategoryId(intval($_GET['id_product']), array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) { $product = new Product(intval($_GET['id_product'])); if (isset($product) and Validate::isLoadedObject($product)) { $ActiveCategory = (int) $product->id_category_default; } } else { $ActiveCategory = (int) $this->context->cookie->last_visited_category; } } if ($ActiveCategory !== null) { $resultCat = Db::getInstance()->ExecuteS(' SELECT * FROM ' . _DB_PREFIX_ . 'admevo_button_link_cat WHERE id_link_cat=' . $ActiveCategory); } $MDParameters = $this->getParameters(); $MDConfiguration = $this->getConfigurations(); if (sizeof($MDConfiguration)) { foreach ($MDConfiguration as $kButton => $ValButton) { $tabLinkButton[$ValButton['id_button']] = array(); $tabIdLinkCat[$ValButton['id_button']] = array(); $tabLinkCustom[$ValButton['id_button']] = array(); $CatMenu = array(); $CatMenu = $this->getButtonLinksCat($ValButton['id_button']); $LinkButton = $this->getButtonLinks($ValButton['id_button']); if (array_key_exists(0, $LinkButton)) { $linkButton = $LinkButton[0]['link']; } else { $linkButton = ""; } $tabLinkButton[$ValButton['id_button']][] = basename($linkButton); if (sizeof($CatMenu)) { foreach ($CatMenu as $kMenu => $ValCat) { $tabIdLinkCat[$ValButton['id_button']][$ValCat['id_link_cat']] = $ValCat['id_link_cat']; $DescendantCateogries = Db::getInstance()->ExecuteS(' SELECT * FROM ' . _DB_PREFIX_ . 'category WHERE id_parent=' . $ValCat['id_link_cat']); if (sizeof($DescendantCateogries)) { foreach ($DescendantCateogries as $kDescCat => $ValDescCat) { $tabIdLinkCat[$ValButton['id_button']][$ValDescCat['id_category']] = $ValDescCat['id_category']; } } } } $CustomMenu = array(); $CustomMenu = $this->getButtonLinksCustom($ValButton['id_button'], $this->context->cookie->id_lang); if (sizeof($CustomMenu)) { foreach ($CustomMenu as $kMenu => $ValMenu) { $tabLinkCustom[$ValButton['id_button']][$ValMenu['id_custom']] = basename($ValMenu['link']); $CustomMenuUnder = array(); $CustomMenuUnder = $this->getButtonLinksCustomUnder($ValButton['id_button'], $ValMenu['id_custom'], $this->context->cookie->id_lang); if (sizeof($CustomMenuUnder)) { foreach ($CustomMenuUnder as $kDescCustom => $ValDescCustom) { $tabLinkCustom[$ValButton['id_button']][$ValDescCustom['id_custom']] = basename($ValDescCustom['link']); } } } } } } if (sizeof($MDConfiguration)) { $b = 0; foreach ($MDConfiguration as $kButton => $ValButton) { $LinkButton = $this->getButtonLinks($ValButton['id_button']); !array_key_exists(0, $LinkButton) ? $linkButton = "#" : ($linkButton = $LinkButton[0]['link']); $this->_menu .= '<li style="background-color: #' . $ValButton['buttonColor'] . '" class="liBouton liBouton' . $b . '">' . $this->eol; strpos(strtolower($ValButton['name_button']), "<br />") ? $decal = "margin-top : -5px;" : ($decal = ""); $this->_menu .= '<div' . ($decal != 0 ? ' style="' . $decal . '"' : '') . '><a href="' . $linkButton . '" ' . ($linkButton == "#" ? "onclick='return false'" : false) . ' class="buttons" ' . (in_array($ActiveCategory, $tabIdLinkCat[$ValButton['id_button']]) || in_array(basename($_SERVER['REQUEST_URI']), $tabLinkCustom[$ValButton['id_button']]) || in_array(basename($_SERVER['REQUEST_URI']), $tabLinkButton[$ValButton['id_button']]) ? 'style="background-position : 0 -' . $MDParameters[0]['MenuHeight'] . 'px; color: #' . $MDParameters[0]['ColorFontMenuHover'] . '"' : false) . '>' . $ValButton['name_button'] . '</a></div>' . $this->eol; $CatMenu = array(); $CatMenu = $this->getButtonLinksCat($ValButton['id_button']); $CustomMenu = array(); $CustomMenu = $this->getButtonLinksCustom($ValButton['id_button'], $this->context->cookie->id_lang); $NbColsMax = $this->getMaxColumns($ValButton['id_button']); $MaxCols = 0; $MaxLines = 0; $tabLines = array(); $m = 0; if (sizeof($CatMenu)) { foreach ($CatMenu as $kMenu => $ValCat) { $tabLines[$kButton][$ValCat['num_ligne']] = $ValCat['num_ligne']; $tabLinesOrder[$kButton][$ValCat['num_ligne']][$ValCat['num_column']] = $ValCat['num_column']; $tabLinesDatas[$kButton][$ValCat['num_ligne']][$ValCat['num_column']][$m] = $ValCat; $tabLinesType[$kButton][$ValCat['num_ligne']][$ValCat['num_column']][$m] = 'category'; $tabColumn[$kButton][$ValCat['num_ligne']] = $ValCat['num_column']; $tabColumnOrder[$kButton][$ValCat['num_column']][$ValCat['num_ligne']] = $ValCat['num_ligne']; $tabColumnDatas[$kButton][$ValCat['num_column']][$ValCat['num_ligne']][$m] = $ValCat; $tabColumnType[$kButton][$ValCat['num_column']][$ValCat['num_ligne']][$m] = 'category'; $m++; $MaxCols < $ValCat['num_column'] * 1 ? $MaxCols = $ValCat['num_column'] : false; $MaxLines < $ValCat['num_ligne'] * 1 ? $MaxLines = $ValCat['num_ligne'] : false; } } if (sizeof($CustomMenu)) { foreach ($CustomMenu as $kCustom => $ValCustom) { $tabLines[$kButton][$ValCustom['num_ligne']] = $ValCustom['num_ligne']; $tabLinesOrder[$kButton][$ValCustom['num_ligne']][$ValCustom['num_column']] = $ValCustom['num_column']; $tabLinesDatas[$kButton][$ValCustom['num_ligne']][$ValCustom['num_column']][$m] = $ValCustom; $tabLinesType[$kButton][$ValCustom['num_ligne']][$ValCustom['num_column']][$m] = 'custom'; $tabColumn[$kButton][$ValCustom['num_ligne']] = $ValCustom['num_column']; $tabColumnOrder[$kButton][$ValCustom['num_column']][$ValCustom['num_ligne']] = $ValCustom['num_ligne']; $tabColumnDatas[$kButton][$ValCustom['num_column']][$ValCustom['num_ligne']][$m] = $ValCustom; $tabColumnType[$kButton][$ValCustom['num_column']][$ValCustom['num_ligne']][$m] = 'custom'; $m++; $MaxCols < $ValCustom['num_column'] * 1 ? $MaxCols = $ValCustom['num_column'] : false; $MaxLines < $ValCustom['num_ligne'] * 1 ? $MaxLines = $ValCustom['num_ligne'] : false; } } if (array_key_exists($kButton, $tabLines)) { if (sizeof($tabLines[$kButton])) { $this->_menu .= '<div class="sub" style="width: ' . ($MDParameters[0]['MenuWidth'] - 2) . 'px; background-color: #' . $ValButton['buttonColor'] . '; ' . ($ValButton['img_name_background'] != "" ? 'background-image: url(' . $this->_path . 'views/img/menu/' . $ValButton['img_name_background'] . '); background-repeat:no-repeat; background-position:top left; ' : false) . ' ">' . $this->eol; $this->_menu .= '<table class="megaDrownTable" cellpadding="0" cellspacing="0" width="100%">'; if ($MDParameters[0]['stateTR1'] == "on") { $this->_menu .= '<tr style="height:' . $MDParameters[0]['heightTR1'] . 'px">'; $MDParameters[0]['stateTD1'] == "on" ? $nbColspan = 2 : ($nbColspan = 1); $this->_menu .= '<td class="megaDrownTR1" valign="top" colspan="' . $nbColspan . '">' . $this->eol; $this->_menu .= $ValButton['detailSubTR'] == "" ? " " : html_entity_decode($ValButton['detailSubTR']); $this->_menu .= '</td>'; $this->_menu .= '<td rowspan="2" class="megaDrownTD3" valign="top" style="width:' . $MDParameters[0]['widthTD3'] . 'px">' . ($ValButton['detailSub'] == "" ? " " : html_entity_decode($ValButton['detailSub'])) . '</td>' . $this->eol; $this->_menu .= '</tr>'; } $this->_menu .= '<tr>'; if ($MDParameters[0]['stateTD1'] == "on") { $this->_menu .= '<td class="megaDrownTD1" valign="top" style="width:' . $MDParameters[0]['widthTD1'] . 'px">' . $this->eol; if ($ValButton['img_name'] != '') { if ($ValButton['img_link'] != '') { $this->_menu .= '<a href="' . urldecode($ValButton['img_link']) . '" style="float:none; margin:0; padding:0">'; } $this->_menu .= '<img src="' . $this->_path . 'views/img/menu/' . $ValButton['img_name'] . '" style="border:0px" alt="' . $ValButton['img_name'] . '"/>' . $this->eol; if ($ValButton['img_link'] != '') { $this->_menu .= '</a>'; } } $this->_menu .= '<br />' . html_entity_decode($ValButton['detailSubLeft']) . '</td>'; } $this->_menu .= '<td class="megaDrownTD2" valign="top">' . $this->eol; $this->_menu .= '<table class="MegaEvoLinks" style="border:0px">' . $this->eol; $this->_menu .= '<tr>' . $this->eol; for ($c = 1; $c <= $MaxCols; $c++) { $this->_menu .= '<td valign="top" class="col' . $c . '">' . $this->eol; for ($l = 1; $l <= $MaxLines; $l++) { if (array_key_exists($c, $tabColumnDatas[$kButton])) { if (array_key_exists($l, $tabColumnDatas[$kButton][$c])) { if (sizeof(@$tabColumnDatas[$kButton][$c][$l])) { $this->_menu .= '<table border="0" style="width:' . $MDParameters[0]['columnSize'] . 'px">' . $this->eol; foreach ($tabColumnDatas[$kButton][$c][$l] as $keyMenu => $ValMenu) { $this->_menu .= '<tr>' . $this->eol; $this->_menu .= '<td style="width:' . $MDParameters[0]['columnSize'] . 'px" class="ligne' . $l . '">' . $this->eol; switch ($tabColumnType[$kButton][$c][$l][$keyMenu]) { case 'category': $category = new Category((int) $ValMenu['id_link_cat']); if (!$category->checkAccess($this->context->customer->id)) { break; } else { $this->_menu .= '<ul>' . $this->eol; $NameCategory = $this->getNameCategory($ValMenu['id_link_cat'], $this->context->cookie->id_lang, $ValButton['id_button']); $NameSubstitute = $this->getNameSubstitute($ValMenu['id_link_cat'], $this->context->cookie->id_lang, $ValButton['id_button']); $Category = new Category(intval($ValMenu['id_link_cat']), intval($this->context->cookie->id_lang)); $rewrited_url = $this->link->getCategoryLink($ValMenu['id_link_cat'], $Category->link_rewrite); $this->_menu .= ' <li class="stitle"> <a href="' . $rewrited_url . '" style="text-align:left">' . (trim($NameSubstitute[0]['name_substitute']) != '' ? $NameSubstitute[0]['name_substitute'] : $NameCategory[0]['name']) . '</a> </li>' . $this->eol; if ($ValMenu['view_products'] != 'on') { $NameCategoryUnder = array(); $NameCategoryUnder = $this->getNameCategoryUnder($ValMenu['id_link_cat'], $ValButton['id_button']); if (sizeof($NameCategoryUnder)) { foreach ($NameCategoryUnder as $KUnderCat => $ValUnderCat) { $Category = new Category(intval($ValUnderCat['id_category']), intval($this->context->cookie->id_lang)); if ($Category->checkAccess($this->context->customer->id)) { $rewrited_url = $this->link->getCategoryLink($ValUnderCat['id_category'], $Category->link_rewrite); $NameCategoryUnder = $this->getNameCategory($ValUnderCat['id_category'], $this->context->cookie->id_lang, $ValButton['id_button']); $NameSubstitute = $this->getNameSubstitute($ValUnderCat['id_category'], $this->context->cookie->id_lang, $ValButton['id_button']); $this->_menu .= ' <li> <a href="' . $rewrited_url . '" style="text-align:left">' . (trim($NameSubstitute[0]['name_substitute']) != '' ? $NameSubstitute[0]['name_substitute'] : $NameCategoryUnder[0]['name']) . ' </a> </li>' . $this->eol; } } } } else { $NameProductsUnder = array(); $NameProductsUnder = $this->getProductsUnder($ValMenu['id_link_cat'], $this->context->cookie->id_lang, $this->context->shop->id); if (sizeof($NameProductsUnder)) { foreach ($NameProductsUnder as $KUnderProd => $ValUnderProd) { $Products = new Product(intval($ValUnderProd['id_product']), true, intval($this->context->cookie->id_lang)); $rewrited_url = $Products->getLink(); $NameProduct = $Products->name; $this->_menu .= '<li><a href="' . $rewrited_url . '" style="text-align:left">' . (strlen($NameProduct) > 20 ? substr($NameProduct, 0, 40) . "..." : $NameProduct) . '</a></li>' . $this->eol; } } } $this->_menu .= '</ul>' . $this->eol; } break; case 'custom': $this->_menu .= '<ul>' . $this->eol; $this->_menu .= '<li class="stitle"><a href="' . $ValMenu['link'] . '" ' . ($ValMenu['link'] == "#" || $ValMenu['link'] == "" ? "onclick='return false'" : false) . ' style="text-align:left">' . $ValMenu['name_menu'] . '</a></li>' . $this->eol; $NameLinkUnder = array(); $NameLinkUnder = $this->getButtonLinksCustomUnder($ValButton['id_button'], $ValMenu['id_custom'], $this->context->cookie->id_lang); if (sizeof($NameLinkUnder)) { foreach ($NameLinkUnder as $KUnderLink => $ValUnderLink) { $this->_menu .= '<li><a href="' . $ValUnderLink['link'] . '" ' . ($ValUnderLink['link'] == "#" || $ValUnderLink['link'] == "" ? "onclick='return false'" : false) . ' style="text-align:left">' . $ValUnderLink['name_menu'] . '</a></li>' . $this->eol; } } $this->_menu .= '</ul>' . $this->eol; break; } $this->_menu .= '</td>' . $this->eol; $this->_menu .= '</tr>' . $this->eol; } $this->_menu .= '</table>' . $this->eol; } } } } $this->_menu .= '</td>' . $this->eol; } $this->_menu .= '</tr>' . $this->eol; $this->_menu .= '</table>' . $this->eol; $this->_menu .= '</td>' . $this->eol; //Colonne droite; if ($MDParameters[0]['stateTD3'] == "on" && $MDParameters[0]['stateTR1'] != "on") { $this->_menu .= '<td class="megaDrownTD3" valign="top" style="width:' . $MDParameters[0]['widthTD3'] . 'px">' . ($ValButton['detailSub'] == "" ? " " : html_entity_decode($ValButton['detailSub'])) . '</td>' . $this->eol; } $this->_menu .= '</tr></table></div>' . $this->eol; } } $this->_menu .= '</li>' . $this->eol; $b++; } } }