Contributions

Other (Category Index)
Search: 

Fix for admin catalog - delete products issue

==============================================
Fix "delete all products and categories" issue
==============================================
History:
Byron Weiss <webmaster@newplanetmagic.com>
Jan.14.2004 Version v1.0
(Submitted to contributions on Sep.10.2004)
==============================================

Please refer to this forum topic:
http://forums.oscommerce.com/index.php?showtopic=71455&st=0

==============================================

Problem: All categories and products are deleted after deleting a category or product.

Cause: This problem was found when the browser's BACK button is used to return to the product list after deleting a product or category. After backing up pages, "categories_id" is set to 0 which is the catalog's root location.

Fix: I wrote a simple check to make sure you can never delete the entire catalog in one action. ($categories_id can never equal 0)


** FILE: catalog/admin/categories.php

** FIND code beginning with...

case 'delete_category_confirm':
if (isset($HTTP_POST_VARS['categories_id'])) {
$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);


** ADD immediately AFTER with this code...

// BEGIN Prevent categories_id = 0
if($categories_id == 0) {
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
break;
}
// END Prevent categories_id = 0


** SAVE the file and you are finished!

Expand All / Collapse All

Fix for admin catalog - delete products issue Byron Weiss 10 Sep 2004

==============================================
Fix "delete all products and categories" issue
==============================================
History:
Byron Weiss <webmaster@newplanetmagic.com>
Jan.14.2004 Version v1.0
(Submitted to contributions on Sep.10.2004)
==============================================

Please refer to this forum topic:
http://forums.oscommerce.com/index.php?showtopic=71455&st=0

==============================================

Problem: All categories and products are deleted after deleting a category or product.

Cause: This problem was found when the browser's BACK button is used to return to the product list after deleting a product or category. After backing up pages, "categories_id" is set to 0 which is the catalog's root location.

Fix: I wrote a simple check to make sure you can never delete the entire catalog in one action. ($categories_id can never equal 0)


** FILE: catalog/admin/categories.php

** FIND code beginning with...

case 'delete_category_confirm':
if (isset($HTTP_POST_VARS['categories_id'])) {
$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);


** ADD immediately AFTER with this code...

// BEGIN Prevent categories_id = 0
if($categories_id == 0) {
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
break;
}
// END Prevent categories_id = 0


** SAVE the file and you are finished!

Note: Contributions are used at own risk.