Community Forums

Random Products

General support for technical problems with OpenCart v1.x

Random Products

Postby robster » Thu Sep 09, 2010 5:00 am

Hi

I am now nearly fully recovered from my 10 year bout of "zencart-itus" and am loving OpenCart.

I do miss one small feature (or maybe not so small I dunno???) that zencart has:

The 'Latest Products' (or as zencart call it - 'New products for xxxmonth') is random new products that change everytime the page is refreshed. The 'newness' of these products is set in admin, for example, added in last 30 days, 60 days, 90 days, etc. There is also a link that allows visitors to see ALL new products not just the 8 or 12 or whatever that are shown on the home page. Is this feature available with OpenCart?

This randomness also applies to 'Specials' and 'Featured Products' in so much as the module shows a limited but changing random selection of these but with a link to show all. This works great and would be excellent on OpenCart

As it is just now, how would a visitor to the site see ALL Latest, Featured or Specials not just the few listed in the respective modules? So for example if I had 100 Specials, but the Specials module just showed 8 (coz 100 would mean a very long scrolling web page) how would they see all 100?

As usual I might be missing something obvious (Q may like to comment here) and there may be a better topic to put this post so mod please move if you feel appropriate!

Thanks

robster
I know my place...!
robster
 
Posts: 393
Joined: Tue Jul 13, 2010 7:08 am

Re: Random Products

Postby mystifier » Thu Sep 09, 2010 8:59 am

Regarding Special Offers. The sidebox, sensibly, show a resticted set controlled by limit in Admin->Extensions->Modules->Specials. With 100 Special Offers, the sidebox might show 6 examples; clicking on the Special Offers link would show paginated pages (configurable in Admin) of all 100.

The sort order is defined by getProductSpecials() in catalog\model\catalog\product.php

To make random specials appear each time the box is refreshed, you would simply need to replace the existing sort stuff (which seems strangely over-complicated):
Code: Select all
$sort_data = array(
   'pd.name',
   'p.sort_order',
   'special',
   'rating',
   'p.price',
   'p.model'
);
         
if (in_array($sort, $sort_data)) {
   if ($sort == 'pd.name' || $sort == 'p.model') {
      $sql .= " ORDER BY LCASE(" . $sort . ")";
   } else {
      $sql .= " ORDER BY " . $sort;
   }
} else {
   $sql .= " ORDER BY p.sort_order";   
}
      
if ($order == 'DESC') {
   $sql .= " DESC";
} else {
   $sql .= " ASC";
}

With:
Code: Select all
$sql .= " ORDER BY Rand()";


Similar would apply to any module, such as Featured. Simply change the sort order to Rand() in the underlying query.

(SELECT * FROM Table ORDER BY Rand() LIMIT 6 would show 6 random records from Table)
User avatar
mystifier
 
Posts: 774
Joined: Tue May 18, 2010 4:15 am

Re: Random Products

Postby robster » Thu Sep 09, 2010 10:42 am

Hi and thanks for the reply.

Everything is understood, except I maybe missing something here again lol but:

clicking on the Special Offers link would show paginated pages (configurable in Admin) of all 100


I can't see any clickable link!!

robster
Last edited by robster on Thu Sep 09, 2010 11:26 am, edited 1 time in total.
I know my place...!
robster
 
Posts: 393
Joined: Tue Jul 13, 2010 7:08 am

Re: Random Products

Postby robster » Thu Sep 09, 2010 11:26 am

Ahhhh forget that last post - I see the link at the top of the page. Doh!!

How would I see ALL Featured products - this is my main desire... (well not my main desire.... but you know what I mean :))

robster
I know my place...!
robster
 
Posts: 393
Joined: Tue Jul 13, 2010 7:08 am

Re: Random Products

Postby mystifier » Thu Sep 09, 2010 12:02 pm

I have a free Extension (in Extensions at the top of this page) to show ALL Products which adds a similar link to Special Offers (which should be in the core ;) ).
User avatar
mystifier
 
Posts: 774
Joined: Tue May 18, 2010 4:15 am

Re: Random Products

Postby Qphoria » Thu Sep 09, 2010 12:36 pm

agreed
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 19015
Joined: Mon Jul 21, 2008 2:02 pm
Donate to Qphoria

Re: Random Products

Postby robster » Thu Sep 09, 2010 12:50 pm

Q, i like your 'Featured Side Box' module and have gotten that from your store - and pretty much everything else too :P

How would I show ALL Featured Products and not be restricted to those 8 or whatever set to show in featured box?

robster
I know my place...!
robster
 
Posts: 393
Joined: Tue Jul 13, 2010 7:08 am


Return to General Support

Who is online

Users browsing this forum: blizeH, gibby, granddaddy, henkbart, ivacocctv, peteremmanuel, rutger, veman and 95 guests

Hosted by Arvixe Web Hosting