Jump to content

limit best-sales


Recommended Posts

I have been searching this forum for a way to limit the number of products displayed in best-sales page because after a while, if you have all products sold at least one time, eventually you end up with another product-list copy page only sorted by sales ( although i am no sure the order is quite right)

so i made a "bypass" on that.

so, what i did was : in best-sales.php i replaced this

$nbProducts = intval(ProductSale::getNbSales());



with this

$nbProducts = 20 ;



My choice was 20 products, but you can change that to whatever ( 3 for top 3 sales)

if anyone has a better solution please share.

Link to comment
Share on other sites

  • 5 years later...

It's in controllers => front => bestsalescontronler.php  :)

Thanks, then I must be doing something wrong because my code looks like:

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, 40, $this->orderBy, $this->orderWay);
		$this->addColorsToProductList($products);
			$this->context->smarty->assign(array(
			'products' => $products,
			'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
			'nbProducts' => 40,
			'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');
}

as you see:

 

'nbProducts' => 40

 

but anyway... in backend is like 94 pages with 12 products each ...

 

post-761238-0-41567600-1465464716_thumb.png

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

  • 1 month later...

Thanks, then I must be doing something wrong because my code looks like:

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, 40, $this->orderBy, $this->orderWay);
		$this->addColorsToProductList($products);
			$this->context->smarty->assign(array(
			'products' => $products,
			'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
			'nbProducts' => 40,
			'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');
}

as you see:

 

'nbProducts' => 40

 

but anyway... in backend is like 94 pages with 12 products each ...

 

attachicon.gifbestsales-problem.png

 

try

 

$this->productSort();

//$nb_products = (int)ProductSale::getNbSales();

$nb_products = 40;

Link to comment
Share on other sites

  • 4 years later...

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