Hi,
Sorry, then I guess I do not understand/do not have a clue on what you are trying to do![]()
Hi,
Sorry, then I guess I do not understand/do not have a clue on what you are trying to do![]()
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):
And replace at the end MAX_DISPLAY_NEW_PRODUCTS with 18 (or whatever number you want).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);
Find the following code:
And add right AFTER it: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']; }
Which will randomly shuffle the 18 products which are on the array $new_products.shuffle($new_products);
Find the following code:
And replace with:for ($x = 0; $x < $no_of_new_products; $x++) {
So it will only display the products we have configured on admin section out of the 18 randomized products.for ($x = 0; $x < MAX_DISPLAY_NEW_PRODUCTS; $x++) {
note: the file to edit is /includes/modules/new_products.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:
And replace with:Code:$specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
Find:Code:$specials_split = new splitPageResults($specials_query_raw, 18);
And replace with:Code: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.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++) {
Last edited by MindTwist; 10-12-2007 at 05:30 AM.
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.
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?
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.
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
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
Bookmarks