} else { // action delete while (!$all_update_products->EOF) { // get all option_values $all_options_values = $db->Execute("select products_options_id, products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id='" . (int) $_POST['options_id'] . "'"); $updated = 'false'; while (!$all_options_values->EOF) { $check_all_options_values = $db->Execute("select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int) $all_update_products->fields['products_id'] . "' and options_id='" . (int) $all_options_values->fields['products_options_id'] . "' and options_values_id='" . (int) $all_options_values->fields['products_options_values_id'] . "'"); if ($check_all_options_values->RecordCount() >= 1) { // delete for this product with Option Name options_value_id // echo '<br>This should be deleted: ' . zen_get_products_name($all_options_values->fields['products_options_id']); // change to delete // should add download delete $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int) $all_update_products->fields['products_id'] . "' and options_id='" . (int) $_POST['options_id'] . "'"); //SBA Start mc12345678 $stock_ids = zen_get_sba_ids_from_attribute($check_all_options_values->fields['products_attributes_id']); if (sizeof($stock_ids) > 0) { $db->Execute("delete from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . "\n where stock_id in (" . implode(',', $stock_ids) . ")"); } //SBA End mc12345678 } else { // skip this option_name does not exist } $all_options_values->MoveNext(); } $all_update_products->MoveNext(); } } // update_action } // no products found
$messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED . ' ID#' . $products_filter, 'success'); $action = ''; $products_filter = (int) $_POST['products_filter']; // reset products_price_sorter for searches etc. zen_update_products_price_sorter($products_filter); zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '¤t_category_id=' . $_POST['current_category_id'])); break; case 'delete_option_name_values': $delete_attributes_options_id = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_POST['products_filter'] . "' and options_id='" . $_POST['products_options_id_all'] . "'"); while (!$delete_attributes_options_id->EOF) { // remove any attached downloads $remove_downloads = $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id= '" . $delete_attributes_options_id->fields['products_attributes_id'] . "'"); // remove all option values $delete_attributes_options_id_values = $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_POST['products_filter'] . "' and options_id='" . $_POST['products_options_id_all'] . "'"); /* START STOCK BY ATTRIBUTES */ $stock_ids = zen_get_sba_ids_from_attribute($delete_attributes_options_id->fields['products_attributes_id']); if (sizeof($stock_ids) > 0) { $delete_attributes_stock_options_id_values = $db->Execute("delete from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " where products_id='" . $_POST['products_filter'] . "' and stock_id in (" . implode(',', $stock_ids) . ")"); } /* END STOCK BY ATTRIBUTES */ $delete_attributes_options_id->MoveNext(); } $action = ''; $products_filter = $_POST['products_filter']; $messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED_OPTION_NAME_VALUES . ' ID#' . zen_options_name($_POST['products_options_id_all']), 'success'); // reset products_price_sorter for searches etc. zen_update_products_price_sorter($products_filter); zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '¤t_category_id=' . $_POST['current_category_id'])); break; // attributes copy to product // attributes copy to product
if ($products_only->RecordCount() > 0) { // check existing matching products and add new attributes while (!$products_only->EOF) { $current_products_id = $products_only->fields['products_id']; // check for associated downloads $downloads_remove_query = "select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $current_products_id . "' and options_id='" . $options_id_from . "' and options_values_id='" . $options_values_values_id_from . "'"; $downloads_remove = $db->Execute($downloads_remove_query); //mc12345678 SBA Added Start $downloads_remove_list = array(); while (!$downloads_remove->EOF) { $downloads_remove_list[] = $downloads_remove->fields['products_attributes_id']; $downloads_remove->MoveNext(); } $downloads_remove->Move(0); $downloads_remove->MoveNext(); $stock_ids = zen_get_sba_ids_from_attribute($downloads_remove_list); if (sizeof($stock_ids) > 0) { $db->Execute("delete from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . "\n where stock_id in (" . implode(',', $stock_ids) . ")"); } //mc12345678 SBA Added End $sql = "delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $current_products_id . "' and options_id='" . $options_id_from . "' and options_values_id='" . $options_values_values_id_from . "'"; $delete_selected = $db->Execute($sql); // delete associated downloads while (!$downloads_remove->EOF) { $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "\n where products_attributes_id='" . $downloads_remove->fields['products_attributes_id'] . "'"); $downloads_remove->MoveNext(); } // count deleted attribute $new_attribute++; $products_only->MoveNext(); }