Page 3 of 4 First 1234 LastLast
Results 21 to 30 of 31

Thread: products_new.tpl.php

  1. #21
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Total Contributions For

    MindTwist     $ 0.00
    Rep Power
    15


    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

  2. #22
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Total Contributions For

    MindTwist     $ 0.00
    Rep Power
    15


    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:

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

    Find the following code:

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

    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

  3. #23
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Total Contributions For

    MindTwist     $ 0.00
    Rep Power
    15


    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.
    Last edited by MindTwist; 10-12-2007 at 05:30 AM.

  4. #24
    bkpie
    Guest


    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.

  5. #25
    excaliburwebdesigners
    Guest


    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?

  6. #26
    JohnW
    Guest


    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.

  7. #27
    idllc
    Guest


    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

  8. #28
    Active Member MindTwist's Avatar
    Join Date
    Jun 2007
    Location
    Barcelona, Spain
    Posts
    409
    Total Contributions For

    MindTwist     $ 0.00
    Rep Power
    15


    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)

  9. #29
    idllc
    Guest


    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

  10. #30
    idllc
    Guest


    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

Page 3 of 4 First 1234 LastLast

Similar Threads

  1. limiting products properly in products_new
    By ganz_friedrich in forum osCommerce 2.2 Modification Help
    Replies: 0
    Last Post: 06-10-2005, 04:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •