ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/includes/modules/move_product_confirm.php
Go to the documentation of this file.
00001 <?php
00002 //
00010 if (!defined('IS_ADMIN_FLAG')) {
00011   die('Illegal Access');
00012 }
00013 
00014         $products_id = zen_db_prepare_input($_POST['products_id']);
00015         $new_parent_id = zen_db_prepare_input($_POST['move_to_category_id']);
00016 
00017         $duplicate_check = $db->Execute("select count(*) as total
00018                                         from " . TABLE_PRODUCTS_TO_CATEGORIES . "
00019                                         where products_id = '" . (int)$products_id . "'
00020                                         and categories_id = '" . (int)$new_parent_id . "'");
00021 
00022         if ($duplicate_check->fields['total'] < 1) {
00023           $db->Execute("update " . TABLE_PRODUCTS_TO_CATEGORIES . "
00024                         set categories_id = '" . (int)$new_parent_id . "'
00025                         where products_id = '" . (int)$products_id . "'
00026                         and categories_id = '" . (int)$current_category_id . "'");
00027 
00028           // reset master_categories_id if moved from original master category
00029           $check_master = $db->Execute("select products_id, master_categories_id from " . TABLE_PRODUCTS . " where products_id='" .  (int)$products_id . "'");
00030           if ($check_master->fields['master_categories_id'] == (int)$current_category_id) {
00031             $db->Execute("update " . TABLE_PRODUCTS . "
00032                           set master_categories_id='" . (int)$new_parent_id . "'
00033                           where products_id = '" . (int)$products_id . "'");
00034           }
00035 
00036           // reset products_price_sorter for searches etc.
00037           zen_update_products_price_sorter((int)$products_id);
00038         } else {
00039           $messageStack->add_session(ERROR_CANNOT_MOVE_PRODUCT_TO_CATEGORY_SELF, 'error');
00040         }
00041 
00042         zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
00043 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations