Jump to content

Change The Number Of Pages In The Best-Sales Tpl/php File


Niller

Recommended Posts

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:
* 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

  • 1 year later...

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

  •  eleazar changed the title to Change The Number Of Pages In The Best-Sales Tpl/php File

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...