outlet.ee Posted April 21, 2013 Share Posted April 21, 2013 Since the php shuffle takes up much resource (in my case it was 1.2 seconds extra load time), here is a method of doing it in database. SQL query: SET @a:=0; UPDATE ps_category_product SET position=@a:=@a+1 WHERE `id_category` = 2 ORDER BY RAND() You can put it in the cron job at certain time interval or bookmark it and run it manually. If you don't have default sorting by position, you need to change the homefeatured/homefeatured.php in line 107, change $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)); into $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'position', 'DESC'); Link to comment Share on other sites More sharing options...
PascalVG Posted April 21, 2013 Share Posted April 21, 2013 Nice :-) Thanks for sharing! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now