« See all FAQs for PinShop - Infinite OpenCart Theme

Is it possible to sort products on home page randomly?


Random products on homepage is hard and simple problem in once.
Theme has dynamic ajax loader of products. module latest.tpl gives the command for products and in every loads 1..20 products, 21..40 products, 41..60 products.. It’s same as pagination. If you add randomize command to SQL, command shuffles products every load and products may be repeated. It’s a hard and dirty way.

Simple way is shuffle products in load 1..20. Just add this line:

shuffle($product_data);

into /catalog/model/catalog/product.php, before return $product_data;


if you want shuffle products only on specific page, add following lines to theme/pinshop/template/module/latest.tpl (before first foreach, line 3)
this is example for homepage (sprcific route common/home)
if(!array_key_exists('route',$this->request->get)) {
          shuffle($products);
}
by
by
by
by
by
by