Labels

Tuesday, 5 April 2016

Random product display on featured page in prestashop

If you want Random product display on featured page in prestashop then just 
add 
shuffle($products);

in your modules/homefeatured/tdhomefeatured.php file at line 100 which should make it look something like.


$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));
shuffle($products);

$this->smarty->assign(array(
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
));

return $this->display(__FILE__, 'homefeatured.tpl');
}

}