Jump to content

Rotating homefeatured module


Recommended Posts

I've got the homefeatured module to rotate the products by adding "shuffle($products);"

function hookHome($params)
   {
       global $smarty;
       $category = new Category(1);
       $nb = intval(Configuration::get('HOME_FEATURED_NBR'));
       $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10), 'date_add', 'DESC');
     shuffle($products); 
       $smarty->assign(array(
           'allow_buy_when_out_of_stock' => Configuration::get('PS_ORDER_OUT_OF_STOCK', false),
           'max_quantity_to_allow_display' => Configuration::get('PS_LAST_QTIES'),
           'category' => $category,
           'products' => $products,
           'currency' => new Currency(intval($params['cart']->id_currency)),
           'lang' => Language::getIsoById(intval($params['cookie']->id_lang)),
           'productNumber' => sizeof($products)
       ));
       return $this->display(__FILE__, 'homefeatured.tpl');
   }



now is there any way that : say i have 20 items on the home category, i want homefeatured module to show me 5 products, but i want those 5 products to be rotated from the list of 20. ( at the moment it rotates 5 products from a list of 5(the number set in the homefeatured module)

Link to comment
Share on other sites

×
×
  • Create New...