Limit New ProductsLast Update: 15th September, 2005
Article ID: 264



Introduction

When products are put into the store in one month they are suppose to be removed when the next month comes but they stay in the new products listings from the beginning of input. These older products can be disabled to not show up by using the codes below.

What's New Box

Editing /catalog/products_new.php removes the extra products from the products_new.php page after clicking on the What's New? arrow. We are adding this code right before the "order by" code at the very end:

and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()



In catalog/products_new.php about line 56 find this code:

$Qproducts = $osC_Database->query('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 = :language_id order by p.products_date_added desc, pd.products_name');


Change to:

$Qproducts = $osC_Database->query('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 = :language_id and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added desc, pd.products_name');



New Products Box on First Page

Editing includes/modules/new_products.php removes the extra new products from the new products box on the index.php page.

In catalog/includes/modules/new_products.php around line 14 is this code:

$Qnewproducts = $osC_Database->query('select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from :table_products p, :table_products_description pd where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id order by p.products_date_added desc limit :max_display_new_products');


Change to:

$Qnewproducts = $osC_Database->query('select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from :table_products p, :table_products_description pd where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added desc limit :max_display_new_products');



NOTE: The cache will need to be removed after each editing of this code otherwise the change will not be seen. The cache is kept in the oscommerce_data folder that was the default folder in the original installation or the name that was chosen at this time.

 

 

Trademark Policy | Copyright Policy | Sitemap

Copyright © 2000-2005 osCommerce. All rights reserved.