Post by Chrissy Poo » Mon Jul 12, 2010 4:29 am

I am using the Featured Products box on my Homepage.

I have set the box to display 8 Products. Is there any way to get the box to randomise the products every time the page is refreshed?

I have over 50 products so would be good to randomise between them.

I am running v1.4.8b.

Thanks in Advance :)
Last edited by i2Paq on Tue Jul 20, 2010 4:26 am, edited 1 time in total.
Reason: Topic moved

10% Discount on all Shared and Reseller Hosting Packages at Vidahost.com

Discount Code: DISCOUNT10


Active Member

Posts

Joined
Mon Jun 29, 2009 8:48 am
Location - UK

Post by Chrissy Poo » Wed Jul 14, 2010 5:24 am

I take it I need to use something like:

Code: Select all

order by random()
Just not sure how to implement it, any help?

10% Discount on all Shared and Reseller Hosting Packages at Vidahost.com

Discount Code: DISCOUNT10


Active Member

Posts

Joined
Mon Jun 29, 2009 8:48 am
Location - UK

Post by Xsecrets » Wed Jul 14, 2010 5:25 am

Code: Select all

order by rand()

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Chrissy Poo » Wed Jul 14, 2010 5:32 am

Xsecrets wrote:

Code: Select all

order by rand()
Ah thanks, any idea exactly where to put it?

Having a bad day today ???

10% Discount on all Shared and Reseller Hosting Packages at Vidahost.com

Discount Code: DISCOUNT10


Active Member

Posts

Joined
Mon Jun 29, 2009 8:48 am
Location - UK

Post by hampo1989 » Tue Jul 20, 2010 2:59 am

You want to goto
yourshop.com/opencart/catalog/model/catalog/product.php
go to line 356
add the code

Code: Select all

. "' ORDER BY rand() DESC LIMIT "
and you will end up with this

Code: Select all

    
public function getFeaturedProducts($limit) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_featured f LEFT JOIN " . DB_PREFIX . "product p ON (f.product_id=p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (f.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) 
WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' 
AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY rand() DESC LIMIT " . (int)$limit); 
Now clear the cache.

You can also set the cache to expire every x seconds
go to
yourshop.com/opencart/system/library/cache.php on line 3

Newbie

Posts

Joined
Tue Jul 20, 2010 2:44 am

Post by Chrissy Poo » Tue Jul 20, 2010 3:14 am

Thanks, I ended up doing to the Latest Products Box instead by following this guide:

http://forum.opencart.com/viewtopic.php?f=23&t=12550

:)

10% Discount on all Shared and Reseller Hosting Packages at Vidahost.com

Discount Code: DISCOUNT10


Active Member

Posts

Joined
Mon Jun 29, 2009 8:48 am
Location - UK

Post by sihijau » Wed Aug 04, 2010 12:36 pm

I created a simple one check this out

Newbie

Posts

Joined
Thu Oct 22, 2009 11:35 pm
Location - bandung - indonesia
Who is online

Users browsing this forum: No registered users and 1 guest