Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Random items on home page

Random items on home page

Locked

Views: 1,799

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
3 Sep 2010, 1:57 AM
#1
jefftew avatar

jefftew

New Zenner

Join Date:
Jul 2010
Posts:
66
Plugin Contributions:
0

Random items on home page

I am somewhat confused about something with the default setup for ZenCart.
I have been populating my store by hand. (Major Issues with EZPopulate). And as I am adding the items, I am choosing the ones that I would like to have featured as well a specials.
When I go to check the way that the home page looks, I see that the cycling of items is done by the category that the items are in.
Since I sell seeds, it is very simple to tell that there are only tree, vegetable, or cacti seed on the home page, and not a blend of the other items in other categories.
Is there a setting that I have to change to make a 'blend' of different items, or is this the default method that ZC displays home page items?
I would much prefer that there is a way to display a random cross section of items that I have to offer rather than just the items in a single category of the site.

Site: https://www.oaktreeseed.com
Zen Cart: v1.3.9b (Clean install, no upgrade, only template added.)
Host: GoDaddy.com
Addons: No addons other than what came out of the box (GoDaddy) and the EZPopulate that I am asking about
Customization: Nothing more than the template, some box sizing, and standard changes for esthetics. (I have not changed the /admin/ folder as yet, the site is not up and running live until 30SEPT0)
Started: Immediately following the installation of EZ Populate v1.2.5.4

3 Sep 2010, 2:00 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Random items on home page

What display are you referencing?

3 Sep 2010, 3:49 AM
#3
jefftew avatar

jefftew

New Zenner

Join Date:
Jul 2010
Posts:
66
Plugin Contributions:
0

Re: Random items on home page

On the home page of http://www.oaktreeseed.com It is listed as "New Products For XXXXXXXXXX", and the items that are listed there are the one that I am asking about.
The template I am using employs the same basic layout as ZC out of the box. The center box is where the items that are listed, by it seem category, are cycling through.

Thanks

JT

Site: https://www.oaktreeseed.com
Zen Cart: v1.3.9b (Clean install, no upgrade, only template added.)
Host: GoDaddy.com
Addons: No addons other than what came out of the box (GoDaddy) and the EZPopulate that I am asking about
Customization: Nothing more than the template, some box sizing, and standard changes for esthetics. (I have not changed the /admin/ folder as yet, the site is not up and running live until 30SEPT10)
Started: Immediately following the installation of EZ Populate v1.2.5.4

3 Sep 2010, 7:26 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Random items on home page

New products on home page are random selected by date -
default is all

check admin > config > maximum values > New Product Listing - Limited to ... > select from options

19 Sep 2010, 2:21 AM
#5
fez_o_joe avatar

fez_o_joe

Zen Follower

Join Date:
Sep 2009
Location:
California
Posts:
141
Plugin Contributions:
0

Re: Random items on home page

kobra:

check admin > config > maximum values > New Product Listing - Limited to ... > select from options

I can see where he's coming from on this - as I've built up the database, I've noticed that the 'random' items are all pulled and showing on the side from the same category... it may be a different category on the bottom, but all the items are still in the same area. (new site - https://www.disastersupplycatalog.com)

Anyone know where this 'random' gets seeded from?!?

Or, does the random just mean random category - not item?

Just curious.

19 Sep 2010, 2:53 AM
#6
fez_o_joe avatar

fez_o_joe

Zen Follower

Join Date:
Sep 2009
Location:
California
Posts:
141
Plugin Contributions:
0

Re: Random items on home page

Fez-o Joe:

Anyone know where this 'random' gets seeded from?!?

Or, does the random just mean random category - not item?

OK, after attempting to make sense of \whats_new.php - it appears that it does make a random number pull, then selects from that number, 'plus' to the max amount you've told it to display.

But, it's not a random each time - it's pulling products_id - then just incrementing. ex: it pulls a 220, then displays item 220, 221, 222. :shocking:

What I'd like (and think the intent was) is a true random ... perhaps a pull of item 220, then 42, then 467 to fulfill the display request - that make sense?

Just curious...

29 Sep 2010, 6:33 AM
#7
fez_o_joe avatar

fez_o_joe

Zen Follower

Join Date:
Sep 2009
Location:
California
Posts:
141
Plugin Contributions:
0

Re: Random items on home page

For the 'New Products' aspect of the page:

Fez-o Joe:

OK, after attempting to make sense of \whats_new.php - it appears that it does make a random number pull, then selects from that number, 'plus' to the max amount you've told it to display.

But, it's not a random each time - it's pulling products_id - then just incrementing. ex: it pulls a 220, then displays item 220, 221, 222. :shocking:

What I'd like (and think the intent was) is a true random ... perhaps a pull of item 220, then 42, then 467 to fulfill the display request - that make sense?

Just curious...

I'm wondering if anyone can make sense of this - as it seems like a nice thing to have... be a shame to turn it all off.

Tag.

29 Sep 2010, 7:49 AM
#8
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Random items on home page

Yes, this is how the current version of Zen Cart works, primarily because there isn't (or at least wasn't) a standard SQL way of extracting entries in a random order.

However, this can be done with MySQL. It's been 2-3 years since I've done it but basically if you find the query that pulls the products out for this box and change (or add) to "ORDER BY RAND()" you'll have the result you want.

29 Sep 2010, 5:02 PM
#9
fez_o_joe avatar

fez_o_joe

Zen Follower

Join Date:
Sep 2009
Location:
California
Posts:
141
Plugin Contributions:
0

Re: Random items on home page

Thanks Kuroi - it works. Took a bit to find exactly where on the select it'd like it, but that goes back to my noob coding skills with PHP.

And if in the future someone else is reading this - there's two files and multiple places to update in /includes/modules/new_products and /sideboxes/whats_new

this is an example in the new_products:

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 order by rand()" . $display_limit;

Watch that quotation mark! :shocking: chuckle

29 Sep 2010, 6:54 PM
#10
yoz8225 avatar

yoz8225

New Zenner

Join Date:
Feb 2007
Posts:
22
Plugin Contributions:
0

Re: Random items on home page

I would like to set up "Featured Products" on my home page to appear in random order every time the page is refreshed. Can this be done with settings or by some other means? :shocking:

30 Sep 2010, 1:07 AM
#11
fez_o_joe avatar

fez_o_joe

Zen Follower

Join Date:
Sep 2009
Location:
California
Posts:
141
Plugin Contributions:
0

Re: Random items on home page

yoz8225:

I would like to set up "Featured Products" on my home page to appear in random order every time the page is refreshed. Can this be done with settings or by some other means? :shocking:

It is controlled via the Admin panel (Config/Max Values) and it has the same programming as the New Products... it'll pick a random product_id then increment from there. Just looking over the code in the featured_products.php - it appears akin to the new_products - so the same code mod should work.

Remember to backup. Always.

27 Oct 2010, 3:39 PM
#12
cyberfolli avatar

cyberfolli

New Zenner

Join Date:
Sep 2010
Posts:
64
Plugin Contributions:
0

Re: Random items on home page

What if I wanted to Hard code a specific category say cat id = 1

when i add a where it just defaults to random.. for some reason trying to specify a category in the admin gets me nowhere either!

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                              p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                       from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                       where p.products_id = pd.products_id
                       and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                       and p.products_status = 1 WHERE p.master_categories_id = '1'
                       and p.products_id in (" . $list_of_products . ")";
27 Oct 2010, 3:42 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Random items on home page

You cannot have 2 WHERE statements in there;

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 WHERE p.master_categories_id = '1'
and p.products_id in (" . $list_of_products . ")"; 

you want to add a new AND to that existing WHERE if you are trying to limit the Products to be those coming just from Products using master_categories_id 1 with:

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 
and p.master_categories_id = '1'
and p.products_id in (" . $list_of_products . ")"; 
24 Nov 2010, 12:59 AM
#14
cyberfolli avatar

cyberfolli

New Zenner

Join Date:
Sep 2010
Posts:
64
Plugin Contributions:
0

Re: Random items on home page

Wow thank you.. That was the answer..

24 Nov 2010, 1:04 AM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Random items on home page

Thanks for the update that this worked for you ... :smile:

24 Nov 2010, 3:05 AM
#16
jam1968 avatar

jam1968

New Zenner

Join Date:
Jan 2006
Posts:
12
Plugin Contributions:
0

Re: Random items on home page

I'm trying this aswell, but I don't think I'm using sideboxes. I was wondering what php file that I should look at editig with this code. I would like to show fully randimized products to.
http://www.mutt-lover.com