I am trying to find all products in random order using pagination. But getting an unexpected result. This is my controller code:
$this->paginate = ['maxLimit' => 20];
$articlesData = $this->Products->find('all');
$articlesData->order('RAND()');
$articles = $this->paginate($articlesData);
So I get random result every time, this is the demand of the page. I have 200 products. Suppose first item is item-12 on page one then if I go to the next page and again go to the previous page then the first item should be item-12 but it changed randomly. Is there any solution for this?
I need pagination because products number going to be 1000 soon. And need random results because I don't want that user to see the same first product on the first page. The first product should be on the first page but not on the same location every time. Is there any way that I make paginated array of 20 items in random order?
All suggestions are welcomed.