Zen Cart Logo
Forums / Customization from the Admin / How Do I Randomize New Products On Index Page?

How Do I Randomize New Products On Index Page?

Views: 2,510

Results 1 to 17 of 17
18 Jan 2011, 1:26 AM
#1
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

How Do I Randomize New Products On Index Page?

I just finished adding a whole bunch of items, and they're all appearing on the index page (New Products For January) in the order I entered them.

Due to the nature of the products, I have one photo for about 30 different items...so even though I added several different categories (each with their own photo), no matter how many times I refresh, I end up with a page full of identical items.

Is there any way to set things so that it shows maybe one or two items from one category, but also one or two of another few categories? Even strictly alphabetical would be better than this...but I don't seem to be able to do that, either.

Thank you!!

18 Jan 2011, 8:45 AM
#2
kobra avatar

kobra

Black Belt

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

Re: How Do I Randomize New Products On Index Page?

This is handled by date added
One can edit the items added date in the database

Zen-Venom Get Bitten

18 Jan 2011, 4:30 PM
#3
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

You mean, I can manually set it so that this one was entered on 1/3/10 and that one was entered on 6/9/02?? Where??? Lot of work...but it's the only thing I can think of right now to randomize the screen.

18 Jan 2011, 5:07 PM
#4
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

I looked, but all I could find was the "Date Available" field. How do I change the date entered?

18 Jan 2011, 5:56 PM
#5
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

DK_Scully:

I looked, but all I could find was the "Date Available" field. How do I change the date entered?

I think that this may do what you want... I had to change my 'Admin - Max Values - New Product Listing...' date to '0' (all products) but it does a nice job. Now every page gets a random pick from the entire catalog.

http://www.zen-cart.com/forum/showthread.php?p=952400#post952400

See #13.

18 Jan 2011, 11:12 PM
#6
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

I already had "New Product Listing - Limited to ..." set to 0. It still is pulling everything in the order it was entered. Is some other value affecting this, maybe? :frusty:

19 Jan 2011, 12:13 AM
#7
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

DK_Scully:

I already had "New Product Listing - Limited to ..." set to 0. It still is pulling everything in the order it was entered. Is some other value affecting this, maybe? :frusty:

Not to sound harsh, but did you read the entire post? Ajeh basically shows the programming change needed to randomize the SELECT, there's no admin selections to change - it's a change to the actual php file.

19 Jan 2011, 12:47 AM
#8
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

I did, yes. I followed the link, looked at the php code...and was thoroughly confused. I am a php moron...give me good old html any day! This stuff looks like gibberish and gives me a headache! :frusty: Is it possible to walk me through this in plain English?

19 Jan 2011, 1:07 AM
#9
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

DK_Scully:

I am a php moron...

And I too am a php idiot... but if you know html then getting your feet wet with php should be easy. Literally, Linda has the line in the module to find, and the in the lower box, the change to be made.

Just make sure that you backup the module first, then make the change and upload it.

It'll take three minutes.

From post 8:

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! chuckle

"I have faith in your ability to handle the situation." (<--- old manager line)

19 Jan 2011, 1:40 AM
#10
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

Okay, I made the change in both places and uploaded them to their respective locations. It worked for the What's New module...but not for the New Products module. (And yes, I was careful not to mess with the ".) Now what??

19 Jan 2011, 1:58 AM
#11
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

DK_Scully:

Okay, I made the change in both places and uploaded them to their respective locations. It worked for the What's New module...but not for the New Products module. (And yes, I was careful not to mess with the ".) Now what??

Lines 26 and 48, both? (line number may differ - but there is more than one place to change it)

19 Jan 2011, 6:45 PM
#12
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

I figured it out, whoo hoo!! :clap: Since I'm using the Alyssa Pink template, I had to modify the Alyssa Pink new_products.php file instead of the original one. Now it's working just the way I wanted it to.

Thank you so much for pointing me in the right direction, I really appreciate it!

19 Jan 2011, 10:52 PM
#13
dk_scully avatar

dk_scully

Zen Follower

Join Date:
Jan 2011
Posts:
339
Plugin Contributions:
0

Re: How Do I Randomize New Products On Index Page?

Okay, I thought I had it figured out. But now I lost the entire box of New Products on the index page, and I have no idea what I did wrong. Help???:oops:

22 Jun 2011, 4:10 AM
#14
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

Just had a thought and am hoping that someone else jumps in on this...

Now that the products are randomizing fine, I find that the products with the 'no image' icon are popping up and don't really look good - so... is there a 'case' or if { that one might be able to insert and have it skip products with no 'no image' file? :shocking:

Tag!

22 Jun 2011, 1:27 PM
#15
ajeh avatar

ajeh

Oba-san

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

Re: How Do I Randomize New Products On Index Page?

You could add to the select statements:

                           and p.products_image != ''

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Jun 2011, 3:52 PM
#16
fez_o_joe avatar

fez_o_joe

Zen Follower

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

Re: How Do I Randomize New Products On Index Page?

... and THAT is why you Rock Ajeh!

Thanks.

22 Jun 2011, 4:26 PM
#17
ajeh avatar

ajeh

Oba-san

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

Re: How Do I Randomize New Products On Index Page?

You are most welcome ... glad this resolved the problem you were having ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!