Jump to content

[Solved] homefeatured random products


Recommended Posts

 

tks vekia, but the link is giving error :/
I searched google but all the links point to the same place ..

 

---

Solved changing /modules/homefeatured/homefeatured.php

type hookDisplayHome function:

 

public function hookDisplayHome($params)
{
global $smarty;
 
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
 
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
 
/*$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));*/
 
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'date_add', 'DESC', false, true, true, $nb);
 
shuffle($products);
 
$this->smarty->assign(array(
 
'products' => $products,
 
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
 
'homeSize' => Image::getSize('home_default'),
 
));
 
return $this->display(__FILE__, 'homefeatured.tpl');
}
Link to comment
Share on other sites

so you added shuffle function?

---

I do not quite understand how it works, but basically that was it.
I think the solution to my case was the code "$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'date_add', 'DESC', false, true, true, $nb);"
 
It worked well.
Edited by paulormf (see edit history)
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...