These are often asked & I don't think there is a tip covering all the above, so here's my solutions.
Backup your site files before making any of the changes given.
How to set number of products displayed within categories:
Admin -> Maximum Values -> Search Results
That setting is used for both your normal product display & search results, annoyingly it also sets the display limit in admin!!
How to set number of new products shown on the home page
The products shown on the home page are displayed with the new_products.php module (found in includes/modules) to limit the number shown:
Admin -> Maximum Values -> New Products Module
How to set the maximum age for new products shown on the home page
By default there is no age limit!! The module will simply display products of any age, only limiting the number by the setting above, to set a date limit (or age) you must add some code:
in includes/modules/new_products.php
after:
$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));
add:
$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate);
find:
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . 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);
Replace with:
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and p.products_date_added > '".$ndate."' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p.products_date_added > '".$ndate."' 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);
How to set maximum number of new products shown in the new products page
The products shown in the new products page are displayed with the products_new.php (found in your catalog folder) to limit the number shown:
Admin -> Maximum Values -> New Products Listing
How to set the maximum age for new products displayed in the new products page
By default there is no age limit!! The page will simply display products of any age, only limiting the number by the setting above, to set a date limit (or age) you must add some code:
in products_new.php
find:
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW));
add after:
$ndate = strtotime("-60 days"); // set max age of displayed product
$ndate = strftime("%Y-%m-%d",$ndate);
find:
$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
replace with:
$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and p.products_date_added > '".$ndate."' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
How to set the maximum age for products displayed in the what's new info box
By default there is no age limit!! (Are you detecting a pattern here!) The box will simply display products of any age, randomly selecting a new product from the X number of the latest products. X having been set with:
Admin -> Maximum Values -> Random New Products
To set a age limit (or date limit since added) you must add some code:
in includes/boxes/whats_new.php
after:
Released under the GNU General Public License */
add:
$bdate = strtotime("-60 days"); // set max age of displayed product
$bdate = strftime("%Y-%m-%d",$bdate);
Find:
if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {
Replace with:
if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' and products_date_added > '".$bdate."' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {
Note: with this modification, if there are no products within the date range the what's new box will simply not appear.
I hope that covers its all. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]
If you prefer, I have uploaded the same info plus modified files as a contribution here
Edited by spooks, 18 October 2009 - 01:59 PM.










