public function process() { $this->productSort(); $nbProducts = (int) ProductSale::getNbSales(); $this->pagination($nbProducts); self::$smarty->assign(array('products' => ProductSale::getBestSales((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home'))); }
public function initContent() { if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) { parent::initContent(); $this->productSort(); $nb_products = (int) ProductSale::getNbSales(); $this->pagination($nb_products); if (!Tools::getValue('orderby')) { $this->orderBy = 'sales'; } $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); /************************* /Images Array ******************************/ if (method_exists('Product', 'getProductsImgs')) { $image_array = array(); for ($i = 0; $i < $nb_products; $i++) { if (isset($products[$i]['id_product'])) { $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']); } } $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL); } /************************* /Images Array ******************************/ $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl'); } else { Tools::redirect('index.php?controller=404'); } }
public function initContent() { parent::initContent(); $this->productSort(); $nbProducts = (int) ProductSale::getNbSales(); $this->pagination($nbProducts); $this->context->smarty->assign(array('products' => ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home_default'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl'); }
public function initContent() { if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) { parent::initContent(); $this->productSort(); $nbProducts = (int) ProductSale::getNbSales(); $this->pagination($nbProducts); $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl'); } else { Tools::redirect('index.php?controller=404'); } }
public function renderContent($args, $setting) { # validate module unset($args); $t = array('name' => '', 'html' => ''); $setting = array_merge($t, $setting); $setting['special'] = array(); $setting['bestseller'] = array(); $setting['featured'] = array(); $setting['newproducts'] = array(); $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6; $orderby = $setting['orderby'] ? $setting['orderby'] : 'position'; $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC'; $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3; $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3; $interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000; if ($setting['featured_display'] && $setting['featured_display'] == 1) { $pro_featured = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_featured); $setting['featured'] = $pro_featured; } if ($setting['newarrivals_display'] && $setting['newarrivals_display'] == 1) { $pro_newproducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_newproducts); $setting['newproducts'] = $pro_newproducts; } if ($setting['special_display'] && $setting['special_display'] == 1) { $pro_special = Product::getPricesDrop((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_special); $setting['special'] = $pro_special; } if ($setting['bestseller_display'] && $setting['bestseller_display'] == 1) { $pro_bestseller = ProductSale::getBestSales((int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway); Context::getContext()->controller->addColorsToProductList($pro_bestseller); $setting['bestseller'] = $pro_bestseller; } $setting['itemsperpage'] = $items_page; $setting['columnspage'] = $columns_page; $setting['interval'] = $interval; $setting['scolumn'] = 12 / $columns_page; $setting['homeSize'] = Image::getSize(ImageType::getFormatedName('home')); $setting['myTab'] = 'leoproducttab' . rand(20, rand()); $output = array('type' => 'producttabs', 'data' => $setting); return $output; }
public function initContent() { if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) { parent::initContent(); $this->productSort(); $nbProducts = (int) ProductSale::getNbSales(); $this->pagination($nbProducts); $products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); if ($this->ajax) { $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl'); $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'); $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products)); $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100; echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage)); die; } else { $this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl'); } } else { Tools::redirect('index.php?controller=404'); } }
<?php include dirname(__FILE__) . '/config/config.inc.php'; include dirname(__FILE__) . '/header.php'; include dirname(__FILE__) . '/product-sort.php'; $nbProducts = intval(ProductSale::getNbSales()); include dirname(__FILE__) . '/pagination.php'; $smarty->assign(array('products' => ProductSale::getBestSales(intval($cookie->id_lang), intval($p) - 1, intval($n), $orderBy, $orderWay), 'nbProducts' => $nbProducts)); $smarty->display(_PS_THEME_DIR_ . 'best-sales.tpl'); include dirname(__FILE__) . '/footer.php';
public function hookHome($params) { if (Configuration::get('PS_CATALOG_MODE')) { return; } $currency = new Currency($params['cookie']->id_currency); $bestsellers = ProductSale::getBestSales((int) $params['cookie']->id_lang, 0, 10); if (!$bestsellers && !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) { return; } $best_sellers = array(); if ($bestsellers) { foreach ($bestsellers as $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int) $bestseller['id_product']), $currency); $best_sellers[] = $bestseller; } } $this->smarty->assign(array('best_sellers' => $best_sellers, 'homeSize' => Image::getSize('home_default'))); return $this->display(__FILE__, 'blockbestsellers-home.tpl'); }
public function parseTemplateCategory($output, $smarty) { $output = self::prepareOutput($output); if (Configuration::get('PS_FORCE_SMARTY_2') === "0") { //Smarty v3 template engine //$currentTemplate = substr(basename($smarty->_current_file), 0, -4); $currentTemplate = substr(basename($smarty->template_resource), 0, -4); if ($currentTemplate == 'breadcrumb') { $currentTemplate = 'product'; } elseif ($currentTemplate == 'pagination') { $currentTemplate = 'category'; } $getTemplateVars = 'getTemplateVars'; } else { //Smarty v2 template engine $currentTemplate = $smarty->currentTemplate; $getTemplateVars = 'get_template_vars'; } switch ($currentTemplate) { case 'manufacturer': $currentTemplate = 'manufacturer'; break; case 'best-sales': $currentTemplate = 'bestsellerspage'; break; case 'new-products': $currentTemplate = 'newproductpage'; break; case 'prices-drop': $currentTemplate = 'specialspage'; break; } $tool = $this->loadTool(); if (!$tool->params->profileExists($currentTemplate) || $tool->params->checkValue('enable-effect', 'No', $currentTemplate)) { return self::prepareOutput($output); } $tool->params->setProfile($currentTemplate); global $link; $cookie =& $GLOBALS['magictoolbox']['magiczoomplus']['cookie']; if (method_exists($link, 'getImageLink')) { $_link =& $link; } else { //for Prestashop ver 1.1 $_link =& $this; } switch ($currentTemplate) { case 'homefeatured': $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); //Number of product displayed $products = $category->getProducts(intval($cookie->id_lang), 1, $nb ? $nb : 10); $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; $productImagesData = array(); $useLink = !$tool->params->checkValue('link-to-product-page', 'No'); foreach ($products as $p_key => $product) { $productImagesData[$p_key]['link'] = $useLink ? $link->getProductLink($product['id_product'], $product['link_rewrite']) : ''; $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['thumb'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], 'small'); if ($tool->type == 'circle') { $productImagesData[$p_key]['medium'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('large-image')); } else { $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } } $magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "homefeaturedMagicZoomPlus")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output); break; case 'category': case 'manufacturer': case 'newproductpage': case 'bestsellerspage': case 'specialspage': break; $products = $smarty->{$getTemplateVars}('products'); $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $magiczoomplus = array(); foreach ($products as $product) { $lrw = $product['link_rewrite']; $img = $_link->getImageLink($lrw, $product['id_image'], 'home'); $pattern = '/<li class="ajax_block_product[^"]*">[^<]*<div class="center_block">((?:[^<]*<span[^>]*>[^<]*<\\/span>)?[^<]*<a[^>]*>[^<]*<img[^>]*?src="' . preg_quote($img, '/') . '"[^>]*>[^<]*<\\/a>.*?)<\\/div>[^<]*<div class="right_block">(.*?)<\\/div>(?:[^<]*<br[^>]*>)?[^<]*<\\/li>/is'; $matches = array(); if (preg_match($pattern, $output, $matches)) { $magiczoomplus[] = '<div>' . $matches[1] . '<div class="bottom_block">' . $matches[2] . '</div></div>'; } } if (!empty($magiczoomplus)) { $tool->params->setValue('item-tag', 'div'); $options = $tool->getPersonalOptions('categoryMagicZoomPlus'); $additionalClass = ''; if ($tool->params->checkValue('scroll-style', 'with-borders')) { $additionalClass = ' msborder'; } $magiczoomplus = $options . '<div id="categoryMagicZoomPlus" class="MagicZoomPlus' . $additionalClass . '">' . implode('', $magiczoomplus) . '</div>'; $output = preg_replace('/<ul[^>]*?id="product_list"[^>]*>.*?<\\/ul>/is', $magiczoomplus, $output); $tool->params->setValue('item-tag', 'a'); } break; case 'product': if (!isset($GLOBALS['magictoolbox']['magiczoomplus']['product'])) { //for skip loyalty module product.tpl return self::prepareOutput($output); } $pCount = count($smarty->{$getTemplateVars}('images')); if (!$pCount) { break; } //$product = $smarty->tpl_vars['product']; //get some data from $GLOBALS for compatible with Prestashop modules which reset the $product smarty variable $product = $GLOBALS['magictoolbox']['magiczoomplus']['product']; $productImagesData = array(); $ids = array(); foreach ($smarty->{$getTemplateVars}('images') as $image) { $id_image = intval($image['id_image']); $ids[] = $id_image; if ($image['cover']) { $coverID = $id_image; } $productImagesData[$id_image]['title'] = $product['name']; $productImagesData[$id_image]['thumb'] = $_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $id_image, $tool->params->getValue('selector-image')); if ($tool->type == 'circle') { $productImagesData[$id_image]['medium'] = $_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $id_image, $tool->params->getValue('thumb-image')); $productImagesData[$id_image]['img'] = $_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $id_image, $tool->params->getValue('large-image')); } else { $productImagesData[$id_image]['img'] = $_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $id_image, $tool->params->getValue('thumb-image')); } } if (!isset($coverID)) { // ensure that we have the image break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; $magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "productMagicZoomPlus")); //need img#bigpic for blockcart module $magiczoomplus = '<div style="width:0px;height:0px;overflow:hidden;visibility:hidden;"><img id="bigpic" src="' . $productImagesData[$ids[0]]['img'] . '" /></div>' . $magiczoomplus; $replaced = 0; $pattern = '<img src="[^"]*?' . preg_quote($_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $coverID, 'large'), '/') . '".*?>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output, -1, $replaced); if (!$replaced) { $iTypes = $this->getImagesTypes(); foreach ($iTypes as $iType) { if ($iType != 'large') { $pattern = '<img src="[^"]*?' . preg_quote($_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $coverID, $iType), '/') . '".*?>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output, -1, $replaced); if ($replaced) { break; } } } } //remove selectors $output = preg_replace('/<div id="thumbs_list">.*?<\\/div>/is', '', $output); $output = preg_replace('/<\\!-- thumbnails -->\\s*<div id="views_block"\\s*>.*?<\\/div>/is', '<!-- thumbnails -->', $output); $output = preg_replace('/<\\!-- thumbnails -->\\s*<p[^>]*><a[^>]+reset[^>]+>.*?<\\/a><\\/p>/is', '<!-- thumbnails -->', $output); //remove "View full size" link $output = preg_replace('/<li>[^<]*?<span[^>]*?id="view_full_size"[^>]*?>[^<]*?<\\/span>[^<]*?<\\/li>/is', '', $output); //remove "Display all pictures" link $output = preg_replace('/<p[^>]*>\\s*<span[^>]*?id="wrapResetImages"[^>]*>.*?<\\/span>\\s*<\\/p>/is', '', $output); break; case 'blockspecials': if (version_compare(_PS_VERSION_, '1.4', '<')) { $products = $this->getAllSpecial(intval($cookie->id_lang)); } else { $products = Product::getPricesDrop((int) $cookie->id_lang, 0, 10, false, 'position', 'asc'); } $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; $productImagesData = array(); $useLink = !$tool->params->checkValue('link-to-product-page', 'No'); foreach ($products as $p_key => $product) { if ($useLink && (!isset($_GET['id_product']) || $_GET['id_product'] != $product['id_product'])) { $productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite']); } else { $productImagesData[$p_key]['link'] = ''; } $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['thumb'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], 'small'); if ($tool->type == 'circle') { $productImagesData[$p_key]['medium'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('large-image')); } else { $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } } $magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "blockspecialsMagicZoomPlus")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output); break; case 'blockviewed': $productsViewed = $GLOBALS['magictoolbox']['magiczoomplus']['productsViewed']; $pCount = count($productsViewed); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; $productImagesData = array(); $useLink = !$tool->params->checkValue('link-to-product-page', 'No'); foreach ($productsViewed as $id_product) { $productViewedObj = new Product(intval($id_product), false, intval($cookie->id_lang)); if (!Validate::isLoadedObject($productViewedObj) or !$productViewedObj->active) { continue; } else { $images = $productViewedObj->getImages(intval($cookie->id_lang)); foreach ($images as $image) { if ($image['cover']) { $productViewedObj->cover = $productViewedObj->id . '-' . $image['id_image']; $productViewedObj->legend = $image['legend']; break; } } if (!isset($productViewedObj->cover)) { $productViewedObj->cover = Language::getIsoById($cookie->id_lang) . '-default'; $productViewedObj->legend = ''; } $lrw = $productViewedObj->link_rewrite; if ($useLink && (!isset($_GET['id_product']) || $_GET['id_product'] != $id_product)) { $productImagesData[$id_product]['link'] = $link->getProductLink($id_product, $lrw); } else { $productImagesData[$id_product]['link'] = ''; } $productImagesData[$id_product]['title'] = $productViewedObj->name; $productImagesData[$id_product]['thumb'] = $_link->getImageLink($lrw, $productViewedObj->cover, 'small'); if ($tool->type == 'circle') { $productImagesData[$id_product]['medium'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image')); $productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('large-image')); } else { $productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image')); } } } $magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "blockviewedMagicZoomPlus")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output); break; case 'blockbestsellers': $blockbestsellers = true; case 'blocknewproducts': if (isset($blockbestsellers)) { //$products = $smarty->$getTemplateVars('best_sellers'); //to get with description etc. $products = ProductSale::getBestSales(intval($cookie->id_lang), 0, 4); } else { $products = $smarty->{$getTemplateVars}('new_products'); } $pCount = count($products); if (!$pCount || !$products) { break; } $GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true; $productImagesData = array(); $useLink = !$tool->params->checkValue('link-to-product-page', 'No'); foreach ($products as $p_key => $product) { if ($useLink && (!isset($_GET['id_product']) || $_GET['id_product'] != $product['id_product'])) { $productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite']); } else { $productImagesData[$p_key]['link'] = ''; } $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['thumb'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], 'small'); if ($tool->type == 'circle') { $productImagesData[$p_key]['medium'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('large-image')); } else { $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } } $magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => $currentTemplate . "MagicZoomPlus")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output); break; } return self::prepareOutput($output); }
public function buildSubmenuTree(array $dataset, $frontend = false, $cssgenerator = false) { $id_lang = (int) Context::getContext()->language->id; $id_shop = (int) Context::getContext()->shop->id; $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT'); $tree = array(); foreach ($dataset as $id => &$node) { if ($cssgenerator) { //set style if (isset($node['content_s']['br_top_st'])) { $node['content_s']['br_top_st'] = $this->convertBorderType($node['content_s']['br_top_st']); } if (isset($node['content_s']['br_right_st'])) { $node['content_s']['br_right_st'] = $this->convertBorderType($node['content_s']['br_right_st']); } if (isset($node['content_s']['br_bottom_st'])) { $node['content_s']['br_bottom_st'] = $this->convertBorderType($node['content_s']['br_bottom_st']); } if (isset($node['content_s']['br_left_st'])) { $node['content_s']['br_left_st'] = $this->convertBorderType($node['content_s']['br_left_st']); } } if ($frontend) { if (isset($node['content_s']['title'][$id_lang]) && $node['content_s']['title'][$id_lang] != '') { $node['content_s']['title'] = $node['content_s']['title'][$id_lang]; } elseif (isset($node['content_s']['title'][$id_lang_default]) && $node['content_s']['title'][$id_lang_default] != '') { $node['content_s']['title'] = $node['content_s']['title'][$id_lang_default]; } else { unset($node['content_s']['title']); } if (isset($node['content_s']['href'][$id_lang]) && $node['content_s']['href'][$id_lang] != '') { $node['content_s']['href'] = $node['content_s']['href'][$id_lang]; } elseif (isset($node['content_s']['href'][$id_lang_default]) && $node['content_s']['href'][$id_lang_default] != '') { $node['content_s']['href'] = $node['content_s']['href'][$id_lang_default]; } else { unset($node['content_s']['href']); } if (isset($node['content_s']['legend'][$id_lang]) && $node['content_s']['legend'][$id_lang] != '') { $node['content_s']['legend'] = $node['content_s']['legend'][$id_lang]; } elseif (isset($node['content_s']['legend'][$id_lang_default]) && $node['content_s']['legend'][$id_lang_default] != '') { $node['content_s']['legend'] = $node['content_s']['legend'][$id_lang_default]; } else { unset($node['content_s']['legend']); } if (isset($node['tabtitle'][$id_lang]) && $node['tabtitle'][$id_lang] != '') { $node['tabtitle'] = $node['tabtitle'][$id_lang]; } elseif (isset($node['tabtitle'][$id_lang_default]) && $node['tabtitle'][$id_lang_default] != '') { $node['tabtitle'] = $node['tabtitle'][$id_lang_default]; } else { unset($node['tabtitle']); } //set variouse links if (isset($node['contentType'])) { switch ($node['contentType']) { case 1: if (isset($node['content']['ids'])) { $customhtml = new IqitCreatorHtml((int) $node['content']['ids'], $id_lang); if (Validate::isLoadedObject($customhtml)) { $node['content']['ids'] = $customhtml->html; } } break; case 4: if (isset($node['content']['ids']) && !empty($node['content']['ids'])) { $node['content']['products'] = Product::getProductsProperties($id_lang, $this->getProducts($node['content']['ids'])); $products = $node['content']['products']; $this->addColorsToProductList($node['content']['products']); if (method_exists('Product', 'getProductsImgs')) { $image_array = array(); for ($i = 0; $i < count($products); $i++) { if (isset($products[$i]['id_product'])) { $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']); } } $node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL; } if ($node['content']['view'] == 1 || $node['content']['view'] == 3) { $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']); $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']); $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']); $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']); $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']); } } break; case 2: if (isset($node['content']['ids'])) { if ($node['content']['ids'] == 'n') { if ($node['content']['o'] == 1) { $products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit']); } else { $products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']); } } elseif ($node['content']['ids'] == 's') { if ($node['content']['o'] == 1) { $products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit']); } else { $products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']); } } elseif ($node['content']['ids'] == 'b') { $products = ProductSale::getBestSales($id_lang, 0, (int) $node['content']['limit'], 'sales'); } else { $category = new Category((int) $node['content']['ids'], $id_lang); if ($node['content']['o'] == 1) { $products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], null, null, false, true, true, (int) $node['content']['limit']); } else { $products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], $node['content']['o'], $node['content']['ob']); } } $node['content']['products'] = $products; $this->addColorsToProductList($node['content']['products']); if (method_exists('Product', 'getProductsImgs')) { $image_array = array(); for ($i = 0; $i < count($products); $i++) { if (isset($products[$i]['id_product'])) { $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']); } } $node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL; } if ($node['content']['view'] == 1 || $node['content']['view'] == 3) { $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']); $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']); $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']); $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']); $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']); } } break; case 6: if (isset($node['content']['source'][$id_lang]) && $node['content']['source'][$id_lang] != '') { $node['content']['source'] = $node['content']['source'][$id_lang]; } elseif (isset($node['content']['source'][$id_lang_default]) && $node['content']['source'][$id_lang_default] != '') { $node['content']['source'] = $node['content']['source'][$id_lang_default]; } else { unset($node['content']['source']); } if (isset($node['content']['href'][$id_lang]) && $node['content']['href'][$id_lang] != '') { $node['content']['href'] = $node['content']['href'][$id_lang]; } elseif (isset($node['content']['href'][$id_lang_default]) && $node['content']['href'][$id_lang_default] != '') { $node['content']['href'] = $node['content']['href'][$id_lang_default]; } else { unset($node['content']['href']); } break; case 7: if ($node['content']['view']) { $node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']); $node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']); $node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']); $node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']); $node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']); } break; case 9: $node['content']['module'] = $this->execModuleHook($node['content']['hook'], array(), $node['content']['id_module'], $id_shop); break; } } } if (!$frontend) { if (isset($node['contentType']) && $node['contentType'] == 4) { if (isset($node['content']['ids']) && !empty($node['content']['ids'])) { $node['content']['ids'] = $this->getProducts($node['content']['ids']); } } } if ($node['parentId'] === 0) { $tree[$id] =& $node; } else { if (!isset($dataset[$node['parentId']]['children'])) { $dataset[$node['parentId']]['children'] = array(); } $dataset[$node['parentId']]['children'][$id] =& $node; } } $tree = $this->sortArrayTree($tree); return $tree; }
public function parseTemplateCategory($output, $smarty) { if ($this->isSmarty3) { //Smarty v3 template engine //$currentTemplate = substr(basename($smarty->_current_file), 0, -4); $currentTemplate = substr(basename($smarty->template_resource), 0, -4); if ($currentTemplate == 'breadcrumb') { $currentTemplate = 'product'; } elseif ($currentTemplate == 'pagination') { $currentTemplate = 'category'; } } else { //Smarty v2 template engine $currentTemplate = $smarty->currentTemplate; } if ($this->isPrestaShop15x && $currentTemplate == 'layout') { $matches = array(); $lang = intval($GLOBALS['magictoolbox']['magicscroll']['cookie']->id_lang); if (preg_match_all('/\\[magicscroll(?:\\sid=(\\d+(?:,\\d+)*))?\\]/', $output, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $output = str_replace($match[0], $this->getCustomSlideshow(empty($match[1]) ? '' : $match[1], $lang, false), $output); } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; } if (version_compare(_PS_VERSION_, '1.5.5.0', '>=')) { //NOTE: because we do not know whether the effect is applied to the blocks in the cache $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; } //NOTE: full contents in prestashop 1.5.x if ($GLOBALS['magictoolbox']['magicscroll']['headers'] == false) { $output = preg_replace('/<\\!-- MAGICSCROLL HEADERS START -->.*?<\\!-- MAGICSCROLL HEADERS END -->/is', '', $output); } else { $output = preg_replace('/<\\!-- MAGICSCROLL HEADERS (START|END) -->/is', '', $output); } return $output; } switch ($currentTemplate) { case 'search': case 'manufacturer': //$currentTemplate = 'manufacturer'; break; case 'best-sales': $currentTemplate = 'bestsellerspage'; break; case 'new-products': $currentTemplate = 'newproductpage'; break; case 'prices-drop': $currentTemplate = 'specialspage'; break; case 'blockbestsellers-home': $currentTemplate = 'blockbestsellers_home'; break; case 'product-list': //for 'Layered navigation block' if (strpos($_SERVER['REQUEST_URI'], 'blocklayered-ajax.php') !== false) { $currentTemplate = 'category'; } break; } $tool = $this->loadTool(); if (!$tool->params->profileExists($currentTemplate) || $tool->params->checkValue('enable-effect', 'No', $currentTemplate)) { return $output; } $tool->params->setProfile($currentTemplate); global $link; $cookie =& $GLOBALS['magictoolbox']['magicscroll']['cookie']; if (method_exists($link, 'getImageLink')) { $_link =& $link; } else { //for Prestashop ver 1.1 $_link =& $this; } $output = self::prepareOutput($output); switch ($currentTemplate) { case 'homefeatured': $categoryID = $this->isPrestaShop15x ? Context::getContext()->shop->getCategory() : 1; $category = new Category($categoryID); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); //Number of product displayed $products = $category->getProducts(intval($cookie->id_lang), 1, $nb ? $nb : 10); if (!is_array($products)) { break; } $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $productImagesData = array(); $useLink = $tool->params->checkValue('link-to-product-page', 'Yes'); foreach ($products as $p_key => $product) { $productImagesData[$p_key]['link'] = $useLink ? $link->getProductLink($product['id_product'], $product['link_rewrite'], isset($product['category']) ? $product['category'] : null) : ''; $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } $magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "homefeaturedMagicScroll")); if ($this->isPrestaShop16x) { $magicscroll = '<div id="homefeatured" class="MagicToolboxContainer homefeatured tab-pane">' . $magicscroll . '</div>'; } $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magicscroll, $output); break; case 'category': case 'manufacturer': case 'newproductpage': case 'bestsellerspage': case 'specialspage': case 'search': $products = $smarty->{$this->getTemplateVars}('products'); if (!is_array($products)) { break; } $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $magicscroll = array(); $left_block_pattern = '(?:<div[^>]*?class="left_block"[^>]*>[^<]*' . '((?:<p[^>]*?class="compare"[^>]*>[^<]*' . '<input[^>]*>[^<]*' . '<label[^>]*>[^<]*<\\/label>[^<]*' . '<\\/p>[^<]*)?)' . '<\\/div>[^<]*)?'; foreach ($products as $product) { $lrw = $product['link_rewrite']; $pattern = preg_quote($_link->getImageLink($lrw, $product['id_image'], 'home' . $this->imageTypeSuffix), '/'); $pattern = str_replace('\\-home' . $this->imageTypeSuffix, '\\-[^"]*?', $pattern); $pattern = '/<li[^>]*?class="[^"]*?ajax_block_product[^"]*"[^>]*>[^<]*' . $left_block_pattern . '<div[^>]*?class="center_block"[^>]*>((?:[^<]*<span[^>]*>[^<]*<\\/span>)?[^<]*' . '<a[^>]*>[^<]*<img[^>]*?src="' . $pattern . '"[^>]*>[^<]*(?:<span[^>]*?class="new"[^>]*>.*?<\\/span>[^<]*)?<\\/a>.*?)' . '<\\/div>[^<]*' . '<div[^>]*?class="right_block"[^>]*>(.*?)<\\/div>(?:[^<]*<br[^>]*>)?[^<]*' . '<\\/li>/is'; $matches = array(); if (preg_match($pattern, $output, $matches)) { $left_block = !empty($matches[1]) ? '<div class="left_block">' . $matches[1] . '</div>' : ''; $magicscroll[] = '<div>' . $left_block . $matches[2] . '<div class="bottom_block">' . $matches[3] . '</div></div>'; } } if (!empty($magicscroll)) { $tool->params->setValue('item-tag', 'div'); $options = $tool->getOptionsTemplate('categoryMagicScroll'); $additionalClass = ''; if ($tool->params->checkValue('scroll-style', 'with-borders')) { $additionalClass = ' msborder'; } if ($this->isPrestaShop15x) { $additionalClass .= ' prestashop15x'; } else { $additionalClass .= ' prestashop14x'; } $magicscroll = $options . '<div id="categoryMagicScroll" class="MagicScroll' . $additionalClass . '">' . implode('', $magicscroll) . '</div>'; $magicscroll = strtr($magicscroll, array('\\' => '\\\\', '$' => '\\$')); $output = preg_replace('/<ul[^>]*?id="product_list"[^>]*>.*?<\\/ul>/is', $magicscroll, $output); $tool->params->setValue('item-tag', 'a'); } break; case 'product': if (!isset($GLOBALS['magictoolbox']['magicscroll']['product'])) { //for skip loyalty module product.tpl break; } $images = $smarty->{$this->getTemplateVars}('images'); $pCount = count($images); if (!$pCount) { break; } if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } //$product = $smarty->tpl_vars['product']; //get some data from $GLOBALS for compatible with Prestashop modules which reset the $product smarty variable $product =& $GLOBALS['magictoolbox']['magicscroll']['product']; $cover = $smarty->{$this->getTemplateVars}('cover'); if (!isset($cover['id_image'])) { break; } $coverImageIds = is_numeric($cover['id_image']) ? $product['id'] . '-' . $cover['id_image'] : $cover['id_image']; $productImagesData = array(); $ids = array(); foreach ($images as $image) { $id_image = intval($image['id_image']); $ids[] = $id_image; //if($image['cover']) $coverID = $id_image; $productImagesData[$id_image]['title'] = $image['legend']; $productImagesData[$id_image]['img'] = $_link->getImageLink($product['link_rewrite'], intval($product['id']) . '-' . $id_image, $tool->params->getValue('thumb-image')); } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; $magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "productMagicScroll")); $magicscroll .= '<script type="text/javascript">magictoolboxImagesOrder = [' . implode(',', $ids) . '];</script>'; //need img#bigpic for blockcart module $magicscroll = '<div style="width:0px;height:0px;overflow:hidden;visibility:hidden;"><img id="bigpic" src="' . $productImagesData[$ids[0]]['img'] . '" /></div>' . $magicscroll; /* $imagePatternTemplate = '<img [^>]*?src="[^"]*?__SRC__"[^>]*>'; $patternTemplate = '<a [^>]*>[^<]*'.$imagePatternTemplate.'[^<]*<\/a>|'.$imagePatternTemplate; $patternTemplate = '<span [^>]*?id="view_full_size"[^>]*>[^<]*'. '(?:<span [^>]*?class="[^"]*"[^>]*>[^<]*<\/span>[^<]*)*'. '(?:'.$patternTemplate.')[^<]*'. '(?:<span [^>]*?class="[^"]*?span_link[^"]*"[^>]*>.*?<\/span>[^<]*)*'. '<\/span>|'.$patternTemplate; //NOTE: added support custom theme #53897 $patternTemplate = $patternTemplate.'|'. '<div [^>]*?id="wrap"[^>]*>[^<]*'. '<a [^>]*>[^<]*'. '<span [^>]*?id="view_full_size"[^>]*>[^<]*'. $imagePatternTemplate.'[^<]*'. '<\/span>[^<]*'. '<\/a>[^<]*'. '<\/div>[^<]*'. '<div [^>]*?class="[^"]*?zoom-b[^"]*"[^>]*>[^<]*'. '<a [^>]*>[^<]*<\/a>[^<]*'. '<\/div>'; //NOTE: added support custom theme #54204 $patternTemplate = $patternTemplate.'|'. '<span [^>]*?id="view_full_size"[^>]*>[^<]*'. '<a [^>]*>[^<]*'. '<img [^>]*>[^<]*'. $imagePatternTemplate.'[^<]*'. '<span [^>]*?class="[^"]*?mask[^"]*"[^>]*>.*?<\/span>[^<]*'. '<\/a>[^<]*'. '<\/span>[^<]*'; $patternTemplate = '(?:'.$patternTemplate.')'; //$patternTemplate = '(<div[^>]*?id="image-block"[^>]*>[^<]*)'.$patternTemplate;//NOTE: we need this to determine the main image //NOTE: added support custom theme #53897 $patternTemplate = '(<div [^>]*?(?:id="image-block"|class="[^"]*?image[^"]*")[^>]*>[^<]*)'.$patternTemplate; $srcPattern = preg_quote($_link->getImageLink($product['link_rewrite'], $coverImageIds, 'large'.$this->imageTypeSuffix), '/'); $pattern = str_replace('__SRC__', $srcPattern, $patternTemplate); $replaced = 0; $output = preg_replace('/'.$pattern.'/is', '$1'.$magicscroll, $output, -1, $replaced); if(!$replaced) { $iTypes = $this->getImagesTypes(); foreach($iTypes as $iType) { if($iType != 'large'.$this->imageTypeSuffix) { $srcPattern = preg_quote($_link->getImageLink($product['link_rewrite'], $coverImageIds, $iType), '/'); $noImageSrcPattern = preg_quote($img_prod_dir.$lang_iso.'-default-'.$iType.'.jpg', '/'); $pattern = str_replace('__SRC__', $srcPattern, $patternTemplate); $output = preg_replace('/'.$pattern.'/is', '$1'.$magicscroll, $output, -1, $replaced); if($replaced) break; } } } */ //NOTE: common pattern to match div#image-block tag $pattern = '(<div\\b[^>]*?(?:\\bid\\s*+=\\s*+"image-block"|\\bclass\\s*+=\\s*+"[^"]*?\\bimage\\b[^"]*+")[^>]*+>)' . '(' . '(?:' . '[^<]++' . '|' . '<(?!/?div\\b|!--)' . '|' . '<!--.*?-->' . '|' . '<div\\b[^>]*+>' . '(?2)' . '</div\\s*+>' . ')*+' . ')' . '</div\\s*+>'; //$replaced = 0; //preg_match_all('%'.$pattern.'%is', $output, $__matches, PREG_SET_ORDER); //NOTE: limit = 1 because pattern can be matched with other products, located below the main product $output = preg_replace('%' . $pattern . '%is', '$1' . $magicscroll . '</div>', $output, 1); //remove selectors //$output = preg_replace('/<div [^>]*?id="thumbs_list"[^>]*>.*?<\/div>/is', '', $output); //NOTE: added support custom theme #53897 $output = preg_replace('/<div [^>]*?(?:id="thumbs_list"|class="[^"]*?image-additional[^"]*")[^>]*>.*?<\\/div>/is', '', $output); //NOTE: div#views_block is parent for div#thumbs_list $output = preg_replace('/<div [^>]*?id="views_block"[^>]*>.*?<\\/div>/is', '', $output); //#resetImages link $output = preg_replace('/<\\!-- thumbnails -->[^<]*<p[^>]*><a[^>]+reset[^>]+>.*?<\\/a><\\/p>/is', '<!-- thumbnails -->', $output); //remove "View full size" link $output = preg_replace('/<li>[^<]*<span[^>]*?id="view_full_size"[^>]*?>[^<]*<\\/span>[^<]*<\\/li>/is', '', $output); //remove "Display all pictures" link $output = preg_replace('/<p[^>]*>[^<]*<span[^>]*?id="wrapResetImages"[^>]*>.*?<\\/span>[^<]*<\\/p>/is', '', $output); break; case 'blockspecials': if (version_compare(_PS_VERSION_, '1.4', '<')) { $products = $this->getAllSpecial(intval($cookie->id_lang)); } else { $products = Product::getPricesDrop((int) $cookie->id_lang, 0, 10, false, 'position', 'asc'); } if (!is_array($products)) { break; } $pCount = count($products); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $productImagesData = array(); $useLink = $tool->params->checkValue('link-to-product-page', 'Yes'); foreach ($products as $p_key => $product) { if ($useLink && (!Tools::getValue('id_product', false) || Tools::getValue('id_product', false) != $product['id_product'])) { $productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite'], isset($product['category']) ? $product['category'] : null); } else { $productImagesData[$p_key]['link'] = ''; } $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } $magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "blockspecialsMagicScroll")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magicscroll, $output); break; case 'blockviewed': $productsViewed = $GLOBALS['magictoolbox']['magicscroll']['productsViewed']; $pCount = count($productsViewed); if (!$pCount) { break; } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $productImagesData = array(); $useLink = $tool->params->checkValue('link-to-product-page', 'Yes'); foreach ($productsViewed as $id_product) { $productViewedObj = new Product(intval($id_product), false, intval($cookie->id_lang)); if (!Validate::isLoadedObject($productViewedObj) or !$productViewedObj->active) { continue; } else { $images = $productViewedObj->getImages(intval($cookie->id_lang)); foreach ($images as $image) { if ($image['cover']) { $productViewedObj->cover = $productViewedObj->id . '-' . $image['id_image']; $productViewedObj->legend = $image['legend']; break; } } if (!isset($productViewedObj->cover)) { $productViewedObj->cover = Language::getIsoById($cookie->id_lang) . '-default'; $productViewedObj->legend = ''; } $lrw = $productViewedObj->link_rewrite; if ($useLink && (!Tools::getValue('id_product', false) || Tools::getValue('id_product', false) != $id_product)) { $productImagesData[$id_product]['link'] = $link->getProductLink($id_product, $lrw, $productViewedObj->category); } else { $productImagesData[$id_product]['link'] = ''; } $productImagesData[$id_product]['title'] = $productViewedObj->name; $productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image')); } } $magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "blockviewedMagicScroll")); $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magicscroll, $output); break; case 'blockbestsellers': case 'blockbestsellers_home': case 'blocknewproducts': case 'blocknewproducts_home': if (in_array($currentTemplate, array('blockbestsellers', 'blockbestsellers_home'))) { $nb_products = $tool->params->getValue('max-number-of-products', $currentTemplate); //$products = $smarty->{$this->getTemplateVars}('best_sellers'); //to get with description etc. $products = ProductSale::getBestSales(intval($cookie->id_lang), 0, $nb_products); } else { $products = $smarty->{$this->getTemplateVars}('new_products'); } if (!is_array($products)) { break; } $pCount = count($products); if (!$pCount || !$products) { break; } $GLOBALS['magictoolbox']['magicscroll']['headers'] = true; if ($pCount < $tool->params->getValue('items')) { $tool->params->setValue('items', $pCount); } $productImagesData = array(); $useLink = $tool->params->checkValue('link-to-product-page', 'Yes'); foreach ($products as $p_key => $product) { if ($useLink && (!Tools::getValue('id_product', false) || Tools::getValue('id_product', false) != $product['id_product'])) { $productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite'], isset($product['category']) ? $product['category'] : null); } else { $productImagesData[$p_key]['link'] = ''; } $productImagesData[$p_key]['title'] = $product['name']; $productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image')); } $magicscroll = $tool->getMainTemplate($productImagesData, array("id" => $currentTemplate . "MagicScroll")); if ($this->isPrestaShop16x) { if ($currentTemplate == 'blockbestsellers_home') { $magicscroll = '<div id="blockbestsellers" class="MagicToolboxContainer blockbestsellers tab-pane">' . $magicscroll . '</div>'; } else { if ($currentTemplate == 'blocknewproducts_home') { $magicscroll = '<div id="blocknewproducts" class="MagicToolboxContainer blocknewproducts tab-pane active">' . $magicscroll . '</div>'; } } } $pattern = '<ul[^>]*?>.*?<\\/ul>'; $output = preg_replace('/' . $pattern . '/is', $magicscroll, $output); break; } return self::prepareOutput($output); }