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 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() { 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 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';