osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 

products_new.tpl.php

This is a discussion on products_new.tpl.php within the osCMax v2 Customization/Mods forums, part of the osCMax v2.0 Forums category; Hi, Sorry, then I guess I do not understand/do not have a clue on what you are trying to ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Customization/Mods

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Reply

 

LinkBack Thread Tools
  #21  
Old 10-09-2007, 11:20 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 256
Thanks: 7
Thanked 21 Times in 20 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: products_new.tpl.php

Hi,
Sorry, then I guess I do not understand/do not have a clue on what you are trying to do
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22  
Old 10-09-2007, 12:09 PM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 256
Thanks: 7
Thanked 21 Times in 20 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: products_new.tpl.php

Quote:
Originally Posted by adamr415 View Post
If I wanted this to randomly select from the last, say 18 products entered, how would i do that
This sounded good to me, so I did this on my site.

My config on admin is to display the X latest products for the month. I did the changes from JohnW so it will just show the X latest products added, no matter what month they were added.

But since I do not add products often, I thought it would be better to have them change a little bit, so I have changed it now so it will randomly display 6 products out of the 18 last ones added.

Find the 2 following lines (they are close, but not toguether):

Code:
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
And replace at the end MAX_DISPLAY_NEW_PRODUCTS with 18 (or whatever number you want).

Find the following code:

Code:
   if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0) {
      while ($_new_products = tep_db_fetch_array($new_products_query)) {
    $new_products[] = $_new_products;
    $list_of_prdct_ids[] = $_new_products['products_id'];
    }
And add right AFTER it:

Quote:
shuffle($new_products);
Which will randomly shuffle the 18 products which are on the array $new_products.

Find the following code:

Quote:
for ($x = 0; $x < $no_of_new_products; $x++) {
And replace with:

Quote:
for ($x = 0; $x < MAX_DISPLAY_NEW_PRODUCTS; $x++) {
So it will only display the products we have configured on admin section out of the 18 randomized products.



note: the file to edit is /includes/modules/new_products.php
__________________
MindTwist of Twisted Reality and Twisted Tienda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to MindTwist For This Useful Post:
nefertari7 (10-12-2007)
  #23  
Old 10-12-2007, 05:05 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 256
Thanks: 7
Thanked 21 Times in 20 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: products_new.tpl.php

Here is another version to randomize the special products being shown on the main page. I also did it so it will take the latest 18 "special" products (hardcoded), and shown 3 random ones (configured on the admin section)

Find:

Code:
   $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
And replace with:

Code:
   $specials_split = new splitPageResults($specials_query_raw, 18);
Find:

Code:
     for ($x = 0; $x < $no_of_specials; $x++) {
And replace with:

Code:
shuffle($specials);
if ($no_of_specials > MAX_DISPLAY_SPECIAL_PRODUCTS) {
   $no_of_specials = MAX_DISPLAY_SPECIAL_PRODUCTS;
}
    for ($x = 0; $x < $no_of_specials; $x++) {
Now instead of showing the last X special products (as configured in your admin section), it will show X random special products out of the 18 ones it can find.
__________________
MindTwist of Twisted Reality and Twisted Tienda

Last edited by MindTwist; 10-12-2007 at 05:30 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to MindTwist For This Useful Post:
bkpie (12-22-2007), nefertari7 (10-12-2007)
  #24  
Old 12-22-2007, 11:41 AM
osCMax Testing Team
 
Join Date: Sep 2004
Posts: 292
Thanks: 23
Thanked 34 Times in 33 Posts
Rep Power: 5
bkpie has a spectacular aura aboutbkpie has a spectacular aura about
Default Re: products_new.tpl.php

John's and Mindtwists fixes work as stated and now the month issue is gone via John's and it will randomly change the 3 new products on my homepage (3 set in admin)between 24 products(set in new_products.php) as in Mindtwists change. That is wonderful

However when you click on the new products link from the homepage it shows all my over 1000 products 3 a page as per admin based on date added newest first. What would I change so it will only show the last 24 products added to my site based on date added. I have tried a couple things but they did not work. I know I am missing something easy.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25  
Old 01-09-2008, 04:38 AM
New Member
 
Join Date: Jun 2007
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
excaliburwebdesigners is on a distinguished road
Default Re: products_new.tpl.php

Quote:
Originally Posted by JohnW View Post
Oops, there is another file I forgot about. In includes/modules/new_products.php look around line 26
Code:
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p where products_status = '1' and month(p.products_date_added) = month(now()) order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
Change to
Code:
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
And around line 29
Code:
    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and month(p.products_date_added) = month(now()) order by p.products_date_added desc limit ". MAX_DISPLAY_NEW_PRODUCTS);
Change to
Code:
    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
I have applied this patch and the other one so both new_products.php and products_new.tpl.php have been updated and its now showing new products on the homepage but if i go to the shops new products page it blank. example New Products - Prime Time Baby

Im 99.9% sure i have updated both files correctly, any idea where its gone wrong?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26  
Old 01-10-2008, 07:34 PM
osCMax Testing Team
 
Join Date: Nov 2002
Location: Orlando
Posts: 200
Thanks: 10
Thanked 22 Times in 14 Posts
Rep Power: 7
JohnW will become famous soon enoughJohnW will become famous soon enough
Default Re: products_new.tpl.php

Yes, you missed my first post which is post #2 on the thread. I didn't really have my act together that day and I had to post twice. Once you do that you'll be in good shape, but post if you have a problem.
__________________
John
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27  
Old 06-02-2008, 10:27 AM
Lurker
 
Join Date: Mar 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
idllc is on a distinguished road
Default Re: products_new.tpl.php

This works great for products_new and specials pages but how about the home page. Nothing changed on my homepage. We just launched site in May and come June no products displayed. Once I made changes noted here they show under new products but not on homepage. I tried on 2 sites with same results. No errors but no change...any additional info would be greatly appreciated.
Scott
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28  
Old 06-02-2008, 10:40 AM
MindTwist's Avatar
Active Member
 
Join Date: Jun 2007
Location: Barcelona, Spain
Posts: 256
Thanks: 7
Thanked 21 Times in 20 Posts
Rep Power: 3
MindTwist will become famous soon enoughMindTwist will become famous soon enough
Default Re: products_new.tpl.php

Quote:
Originally Posted by idllc View Post
This works great for products_new and specials pages but how about the home page. Nothing changed on my homepage. We just launched site in May and come June no products displayed. Once I made changes noted here they show under new products but not on homepage. I tried on 2 sites with same results. No errors but no change...any additional info would be greatly appreciated.
Scott
You should read this full thread again. You missed something, did some changes somewhere else than where you were supposed to do them, etc... The code to change how products are shown on the main page is here (specials AND new products)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to MindTwist For This Useful Post:
idllc (06-02-2008)
  #29  
Old 06-02-2008, 10:46 AM
Lurker
 
Join Date: Mar 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
idllc is on a distinguished road
Default Re: products_new.tpl.php

So when I change the code via post #2 and page 3 of this thread I should show products on the home page correct? It updated the new products page but not homepage. Demo
So my site should be doing more than what it is showing now?
Thanks for the fast reply by the way.
Scott
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30  
Old 06-02-2008, 11:03 AM
Lurker
 
Join Date: Mar 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
idllc is on a distinguished road
Default Re: products_new.tpl.php

Quote:
Originally Posted by MindTwist View Post
You should read this full thread again. You missed something, did some changes somewhere else than where you were supposed to do them, etc... The code to change how products are shown on the main page is here (specials AND new products)
Ok I got it...thanks. Just to summarize for others I used code from post 2 on page one of this thread, the code on post one of page 3 and then the oops I forgot code on page 3 half way down. Worked like a charm.
Best wishes,
Scott
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
limiting products properly in products_new ganz_friedrich osCommerce 2.2 Modification Help 0 06-10-2005 04:48 AM


All times are GMT -8. The time now is 04:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
Copyright 2008 osCMax