Jump to content

Best Sellers Block > Modify Display Number


vegaskev

Recommended Posts

The best sellers block seems to not have the option in the admin area to select how many products will appear when using it.  I'm curious as to where I would get started in changing the amount of products it displays from the standard 6 to maybe 2 or 3.  Anyone know what file I would modify to achieve this?  I would greatly appreciate any guidance, as I'm still getting acclimated with PrestaShop's MVC style folder & framework structure.  Thanks in advance.  I appreciate it.

Edited by vegaskev (see edit history)
Link to comment
Share on other sites

Hi Vegas,

 

Have a look in /modules/blockbestsellers/blockbestsellers.php, function: (Sample code from Prestashop 1.5.6.2)

	protected function getBestSellers($params)
	{
		if (Configuration::get('PS_CATALOG_MODE'))
			return false;
		if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 5)))
			return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false);

		$bestsellers = array();
		$currency = new Currency($params['cookie']->id_currency);
		$usetax = (Product::getTaxCalculationMethod((int)$this->context->customer->id) != PS_TAX_EXC);
		foreach ($result as &$row)
			$row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency);
		return $result;
	}

There you see the line:

 

        if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 5)))

 
change the number 5 into the amount of products you want to show in the block.
 
 
Remove/turn off cache and reload the front page to see the changes.
 
 
Hope this helps,
pascal.
Link to comment
Share on other sites

@PascalIVG.  Thank you for that.  I'm still a PS noob and trying to get acclimated with everything PS.  In order to retain these changes, wouldn't I place that modified blockbestsellers.php file inside /theme-name/modules/blockbestsellers/ folder in order to avoid losing my changes on PS and module updates?  Please advise.  

Link to comment
Share on other sites

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...