Post by musabka » Sat Oct 22, 2022 3:45 pm

Hello, Can I change the Default Sort Product in Category page to be randomly
in category page the product sort by name, so can I change it to be sorted by random?

Opencart Version 3.0.3.8


Thank you!

Newbie

Posts

Joined
Tue Oct 29, 2019 4:58 am

Post by imdevlper18 » Sat Oct 22, 2022 11:02 pm

You need to edit the 2 files. The path is:

catalog/controller/product/category.php

Find (Line no 21) :

Code: Select all

$sort = 'p.sort_order';
Change this to:

Code: Select all

$sort = 'RAND ()';
Also, change one more file:
catalog/model/catalog/product.php

Find (Line no 165) :

Code: Select all

'p.sort_order',
Add code after above:

Code: Select all

'RAND ()',
Save it. And click the refresh icon on the Extension modifications page. Job done !!

If you are on the 3.x version of the Opencart you can install this extension:
https://www.opencart.com/index.php?rout ... n_id=44314

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by musabka » Sun Oct 23, 2022 5:30 pm

imdevlper18 wrote:
Sat Oct 22, 2022 11:02 pm
You need to edit the 2 files. The path is:

catalog/controller/product/category.php

Find (Line no 21) :

Code: Select all

$sort = 'p.sort_order';
Change this to:

Code: Select all

$sort = 'RAND ()';
Also, change one more file:
catalog/model/catalog/product.php

Find (Line no 165) :

Code: Select all

'p.sort_order',
Add code after above:

Code: Select all

'RAND ()',
Save it. And click the refresh icon on the Extension modifications page. Job done !!

If you are on the 3.x version of the Opencart you can install this extension:
https://www.opencart.com/index.php?rout ... n_id=44314
Thank you very much for your professional reply!
1- I changed

Code: Select all

$sort = 'p.sort_order';
to:

Code: Select all

$sort = 'RAND ()';
Image

2- I added

Code: Select all

'RAND ()',
to catalog/model/catalog/product.php file.
Image

3- I clicked the refresh icon on the Extension modifications page

4- I cleared website cash and browser cash

Unfortunately, nothing has changed.

5- I also tried the extension: https://www.opencart.com/index.php?rout ... n_id=44314

Unfortunately, nothing has changed again.

Did I miss anything or did I do something wrong?

Thank you again & again!

Newbie

Posts

Joined
Tue Oct 29, 2019 4:58 am

Post by imdevlper18 » Sun Oct 23, 2022 6:25 pm

Weird. It works for me.
Please drop me an email at support@cartbinder.com

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by musabka » Sun Oct 23, 2022 7:20 pm

imdevlper18 wrote:
Sun Oct 23, 2022 6:25 pm
Weird. It works for me.
Please drop me an email at support@cartbinder.com
I sent you an email
Best Regards

Newbie

Posts

Joined
Tue Oct 29, 2019 4:58 am
Who is online

Users browsing this forum: Google [Bot] and 23 guests