Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Limit the amount of products


mjohnson

Recommended Posts

Posted

Is there a way to limit the amount of products that can be added to a site. For example I would like to set up a site that allows for a maximum of 250 products total and another with 1000 products total.

Posted

New products are inserted on page:

'catalog/admin/categories.php' Line 208 - case 'insert_product':

 

Since there is no break statement below this line then the

case 'update_product':

comes into effect as well.

 

You need to do a database query directly after this line and count the number of products in the database:

case 'insert_product':

case 'update_product':

 

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS);

$check = tep_db_fetch_array($check_query);

if ($check['total'] > '1000') {

$messageStack->add_session('Product have been exceeded', 'error');

tep_redirect(tep_href_link(FILENAME_CATEGORIES));

}

Lloyd

Posted

I tried doing what was explaine, but I must be doing it wrong. This is what my file looks like:

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));

break;

case 'insert_product':

case 'update_product':

if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {

$action = 'new_product';

} else {

if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);

$products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);

 

$products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

 

$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),

'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),

'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),

'products_date_available' => $products_date_available,

'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),

'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),

'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),

'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));

 

if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {

$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);

}

 

 

Can you show me what it should look like?

 

Thanks

  • 2 months later...
Posted

I requested some help on this and received some one response. Unfortunately I need some more clarification. Can anyone help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...