} reset($products); while (list($key, $value) = each($products)) { $category_ids = ''; for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) { $category_ids .= "'" . (int)$value['categories'][$i] . "', "; } $category_ids = substr($category_ids, 0, -2); $check_query = smn_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and store_id = '" .$store_id . "' and categories_id not in (" . $category_ids . ")"); $check = smn_db_fetch_array($check_query); if ($check['total'] < '1') { $products_delete[$key] = $key; } } // removing categories can be a lengthy process smn_set_time_limit(0); for ($i=0, $n=sizeof($categories); $i<$n; $i++) { smn_remove_category($categories[$i]['id']); } reset($products_delete); while (list($key) = each($products_delete)) { smn_remove_product($key); } } if (USE_CACHE == 'true') { smn_reset_cache_block('categories'); smn_reset_cache_block('also_purchased'); } smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath.'&ID='.$store_id))); break; case 'delete_product_confirm':
function delete_store_category_confirm() { global $store; if (isset($_POST['store_categories_id'])) { $store_categories_id = smn_db_prepare_input($_POST['store_categories_id']); $store_categories = $store->smn_get_store_category_tree($store_categories_id, '', '0', '', true); $store_arr = array(); $store_delete = array(); $sizeof_store_categories = sizeof($store_categories); for ($i = 0, $n = $sizeof_store_categories; $i < $n; $i++) { $store_ids_query = smn_db_query("select store_id from " . TABLE_STORE_TO_CATEGORIES . " where store_categories_id = '" . (int) $store_categories[$i]['id'] . "'"); while ($store_ids = smn_db_fetch_array($store_ids_query)) { $store_arr[$store_ids['store_id']]['store_categories'][] = $store_categories[$i]['id']; } } reset($store_arr); while (list($key, $value) = each($store_arr)) { $store_category_ids = ''; $sizeof_value_store_categories = sizeof($value['store_categories']); for ($i = 0, $n = $sizeof_value_store_categories; $i < $n; $i++) { $store_category_ids .= "'" . (int) $value['store_categories'][$i] . "', "; } $store_category_ids = substr($store_category_ids, 0, -2); $check_query = smn_db_query("select count(*) as total from " . TABLE_STORE_TO_CATEGORIES . " where store_id = '" . (int) $key . "' and store_categories_id not in (" . $store_category_ids . ")"); $check = smn_db_fetch_array($check_query); if ($check['total'] < '1') { $store_delete[$key] = $key; } } // removing store_categories can be a lengthy process smn_set_time_limit(0); $sizeof_store_categories = sizeof($store_categories); for ($i = 0, $n = $sizeof_store_categories; $i < $n; $i++) { smn_remove_store_category($store_categories[$i]['id']); } reset($store_delete); while (list($key) = each($store_delete)) { smn_remove_store($key); } } if (USE_CACHE == 'true') { smn_reset_cache_block('store_categories'); smn_reset_cache_block('also_purchased'); } smn_redirect(smn_href_link(FILENAME_MANAGEMENT, 'sPath=' . $sPath)); }