Contentful: Return entries in a random order

Viewed 887

Is it possible to return entries in a random order through a Contentful Query?
Without specifying a "->where" parameter, it will sort the entries alphabetically.

I've tried using shuffle() and array_rand(), however it doesn't recognise a Contentful object as an array.

Here's what I currently have:

<?php   
$query = new \Contentful\Delivery\Query;
$query->setContentType(PRODUCT_TYPE);

$entries = $client->getEntries($q1->where('fields.images[exists]', 'true')->where('fields.category.sys.id', $entry->getCategory()->getId())->where('limit', '3'));

$array_shuffle = shuffle($entries)

foreach ($array_shuffle as $entry) 
  {}

?>

1 Answers
Related