kanchi.game2016.4 kanchi.game2016.4 - 3 months ago 14x
SQL Question

Open Cart Query for array of random products

I'm using OpenCart 1.5.6 and i just install a module called "CategorySeller" and it show a slides of product by category but the problem is i want the product to be random example i have 10 products and right now it shows product, 1,2,3,4,5 then for the next time the page loads it will show 2,3,5,1,6 and different again for the next time, no particular order i just want to give me a random product

by the way i think this is the code of the query i just dont know how to make it random

if ( isset($setting['product_category']) ) {

foreach( $setting['product_category'] as $product_category ) {
$results = array_merge($results, $this->model_catalog_product->getProducts(array('filter_category_id'=> (int)$product_category, 'start' => 0, 'limit' => $setting['limit'])));
if ( count($results) >= $setting['limit'] ) {
$results = array_slice( $results, 0, $setting['limit']);



Immediately above this line:

if ( count($results) >= $setting['limit'] ) {

Insert the following line:


This will shuffle the order of results before a subset is sliced off.