Niller Posted December 29, 2015 Share Posted December 29, 2015 (edited) Hi. My best sales page on my prestashop 1.5.6.2 shows all sold products, which makes more pages. How can i limit the products, so i only have 1 site with top 10 products etc? Lasse Edited December 29, 2015 by Niller (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted December 30, 2015 Share Posted December 30, 2015 you have to modify the bestSalesController.php file. It's pretty easy to do, just make sure you edit $this->n to match your number and $nb_products to the number of products you want to display, so it does not create other pages Link to comment Share on other sites More sharing options...
Niller Posted December 30, 2015 Author Share Posted December 30, 2015 Hey Nemo. Thanks for answer. I have tried to change it a bit - now it looks like this: - but it shows 10 products per page. <?php /* * 2007-2013 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class BestSalesControllerCore extends FrontController { public $php_self = 'best-sales'; 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, 10, $this->orderBy, $this->orderWay), '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'); } public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'product_list.css'); if (Configuration::get('PS_COMPARATOR_MAX_ITEM')) $this->addJS(_THEME_JS_DIR_.'products-comparison.js'); } } Link to comment Share on other sites More sharing options...
Niller Posted January 1, 2016 Author Share Posted January 1, 2016 bump Link to comment Share on other sites More sharing options...
vekia Posted January 1, 2016 Share Posted January 1, 2016 change 'nbProducts' => $nbProducts to 'nbProducts' => 10, Link to comment Share on other sites More sharing options...
Darussalam Posted November 6, 2017 Share Posted November 6, 2017 Hi Vekia, I changed 'nbProducts' => 72, but best-sellers page (https://dar-us-salam.com/best-sellers) still shows all of the 1362 products. I cleared the cache and also the PageCache but nothing seems to take effect. I checked the BestSalesController.php file via FTP and it is 72. Any suggestions? Thanks Link to comment Share on other sites More sharing options...
Darussalam Posted November 11, 2017 Share Posted November 11, 2017 Hello, I figured out that Jpresta did a override for this controller. Can anyone help me as to how I can restrict the # of best sellers to 72? Here is my BestSalesController.php file: <?php /** * Page Cache powered by Jpresta (jpresta . com) * * @author Jpresta * @copyright Jpresta * @license You are just allowed to modify this copy for your own use. You must not redistribute it. License * is permitted for one Prestashop instance only but you can install it on your test instances. */ class BestSalesController extends BestSalesControllerCore { /* * module: pagecache * date: 2016-12-09 04:32:49 * version: 3.17 */ public function displayAjax() { $this->initHeader(); $result = array(); $index = 0; $nb_products = 72; /* Added by OW */ do { $val = Tools::getValue('hook_' . $index); if ($val !== false) { list($hook_name, $id_module) = explode('|', $val); if (Validate::isHookName($hook_name)) { $result[$hook_name . '_' . (int)$id_module] = Hook::exec($hook_name, array() , (int)$id_module); } } $index++; } while ($val !== false); if (Tools::version_compare(_PS_VERSION_,'1.6','>')) { Media::addJsDef(array( 'isLogged' => (bool)$this->context->customer->isLogged(), 'isGuest' => (bool)$this->context->customer->isGuest(), 'comparedProductsIds' => $this->context->smarty->getTemplateVars('compared_products'), )); $defs = Media::getJsDef(); unset($defs['baseDir']); unset($defs['baseUrl']); $this->context->smarty->assign(array( 'js_def' => $defs, )); $result['js'] = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_.'javascript.tpl'); } $this->context->cookie->write(); header('Content-Type: application/json'); die(Tools::jsonEncode($result)); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now