Post by andriyz » Fri Feb 11, 2011 3:31 am

Hello,
I was wondering if there is a way to display products randomly at default "sort by" option. Right now it seems like it is chosen by date add. I have different brands, so at default settings I have all products of one brand, then below of other ext. I'd like them do display all mixed together.
Thank you

Newbie

Posts

Joined
Fri Oct 15, 2010 6:45 am

Post by Qphoria » Fri Feb 11, 2011 3:46 am

Try this:

1. EDIT: catalog/controller/product/catalog.php

2. FIND:

Code: Select all

$this->data['pagination'] = $pagination->render();
3. BEFORE, ADD:

Code: Select all

shuffle($this->data['products']);

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by hoki » Wed Oct 19, 2011 9:41 pm

Unfortunately this solution incapacitates all other "sort by" options. Any ways to fix this?

Newbie

Posts

Joined
Wed Oct 19, 2011 9:39 pm

Post by Qphoria » Wed Oct 19, 2011 10:54 pm

hoki wrote:Unfortunately this solution incapacitates all other "sort by" options. Any ways to fix this?
well if you want sort by then why would you want a random shuffle?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by hoki » Thu Oct 20, 2011 1:00 am

Qphoria wrote:well if you want sort by then why would you want a random shuffle?
I thought of having a "random sort by option". Is it possible?

Newbie

Posts

Joined
Wed Oct 19, 2011 9:39 pm

Post by vinivst » Sat Oct 11, 2014 12:48 am

Hello, i've solved this problem after searching a lot on internet.

I put the following code:

Code: Select all

if ($this->request->get['sort'] == 'p.sort_order' || !isset($this->request->get['sort'])) 
			{
				shuffle($this->data['products']);
			}
Before this line:

Code: Select all

$this->data['pagination'] = $pagination->render();
As Qphoria have said.

What my code do?

My code test if the sort is seted(not null) or if it haves the main value ("p.sort_order"), if yes, it shuffle the products, if not it just follows the sort that was seted.

Try it out.

Newbie

Posts

Joined
Sat Oct 11, 2014 12:44 am

Post by Time111 » Mon Oct 03, 2016 6:47 am

vinivst wrote:Hello, i've solved this problem after searching a lot on internet.

I put the following code:

Code: Select all

if ($this->request->get['sort'] == 'p.sort_order' || !isset($this->request->get['sort'])) 
			{
				shuffle($this->data['products']);
			}
Before this line:

Code: Select all

$this->data['pagination'] = $pagination->render();
As Qphoria have said.

What my code do?

My code test if the sort is seted(not null) or if it haves the main value ("p.sort_order"), if yes, it shuffle the products, if not it just follows the sort that was seted.

Try it out.
Hi im interested in this feature........ can anyone say how this can be implemented in OC 2.0.3.1

Thanks

~Time

New member

Posts

Joined
Tue Aug 11, 2015 7:46 am
Who is online

Users browsing this forum: No registered users and 8 guests