function import_products($xcart_conf)
{
    extract($xcart_conf);
    extract(cw_vers_diff_attr($conn));
    fout("<br /><br />Import of manufacturers, Products, Categories...<br />");
    $cats = cw_table_copy_from_xcart_lit_sn($conn, 'categories', "categoryid as category_id, parentid as parent_id, if(avail='Y',1,0) as status, category, description, order_by");
    cw_table_copy_from_xcart_lit($conn, 'xcart_categories', 'cw_categories_stats', "categoryid as category_id, views_stats");
    cw_table_copy_from_xcart_lit_sn($conn, 'categories_lng', "UPPER(code) as code, categoryid as category_id, category, description");
    cw_table_copy_from_xcart_lit_sn($conn, 'products_categories', "categoryid as category_id, productid as product_id,\n\t\t  if(main='Y',1,0) as main, orderby");
    $prods = cw_table_copy_from_xcart_comm_sn($conn, 'products', "productid as product_id, if(forsale='Y',1,0) as status");
    cw_table_copy_from_xcart_lit($conn, 'xcart_products', 'cw_products_stats', "productid as product_id, views_stats, sales_stats, del_stats");
    cw_table_copy_from_xcart_lit($conn, 'xcart_products', 'cw_products_warehouses_amount', "productid as product_id, avail");
    cw_table_copy_from_xcart_lit_sn($conn, 'products_lng', "UPPER(code) as code, productid as product_id, product,descr,fulldescr,keywords");
    db_query("TRUNCATE TABLE cw_products_prices");
    $sql = "select priceid as price_id, prc.productid as product_id, quantity, price, list_price,\n\t\tvariantid as variant_id, membershipid as membership_id from xcart_pricing prc\n\t\tleft join xcart_products prd on prc.productid=prd.productid order by product_id, variant_id";
    $prices = cw_query($sql, $conn);
    foreach ($prices as $arr) {
        cw_array2insert_esc('cw_products_prices', $arr);
    }
    // Memberships
    db_query("Delete from cw_memberships where membership_id!=0");
    $mbrsh = cw_query("select * from xcart_memberships  where membershipid!=0", $conn);
    $level = cw_query_first_cell("select level from cw_access_levels  where membership_id=0 and area='A'");
    db_query("Delete from cw_access_levels where membership_id!=0");
    foreach ($mbrsh as $v) {
        extract($v);
        if ($area == 'A' || $area == 'P') {
            $area = 'A';
        } else {
            $area = 'C';
        }
        $membership_id = $membershipid;
        $show_prices = 1;
        cw_array2insert_esc('cw_memberships', compact('membership_id', 'area', 'membership', 'active', 'orderby', 'flag', 'show_prices'));
        if ($area == 'A') {
            cw_array2insert_esc('cw_access_levels', compact('membership_id', 'area', 'level'));
        }
    }
    db_query("Delete from cw_memberships_lng where membership_id!=0");
    $mbrshl = cw_query("select * from xcart_memberships_lng  where membershipid!=0", $conn);
    foreach ($mbrshl as $v) {
        extract($v);
        $membership_id = $membershipid;
        $code = strtoupper($code);
        cw_array2insert_esc('cw_memberships_lng', compact('membership_id', 'code', 'membership'));
    }
    cw_table_copy_from_xcart_lit($conn, 'xcart_products', 'cw_products_memberships', "productid as product_id, 0 as memberships_id");
    cw_table_copy_from_xcart_lit($conn, 'xcart_categories', 'cw_categories_memberships', "categoryid as category_id, 0 as memberships_id");
    $catmem = cw_query("select * from xcart_category_memberships", $conn);
    $prodmem = cw_query("select * from xcart_product_memberships", $conn);
    foreach ($catmem as $v) {
        extract($v);
        $membership_id = $membershipid;
        $category_id = $categoryid;
        cw_array2insert('cw_categories_memberships', compact('category_id', 'membership_id'));
    }
    foreach ($prodmem as $v) {
        extract($v);
        $membership_id = $membershipid;
        $product_id = $productid;
        cw_array2insert('cw_products_memberships', compact('product_id', 'membership_id'));
    }
    // manufacturers
    $mans = cw_table_copy_from_xcart_comm_sn($conn, 'manufacturers', "manufacturerid as manufacturer_id,\n\t\tprovider as warehouse_customer_id, if(avail='Y',1,0) as avail");
    cw_table_copy_from_xcart_comm_sn($conn, 'manufacturers_lng', 'manufacturerid as manufacturer_id, UPPER(code) as code');
    // Set Attributes: 0 for domains; Meta Tags, manufacturer_id for products, etc.
    if ($withcurls) {
        $tmp = cw_query("SELECT * from xcart_clean_urls", $conn);
        $clean_urls = array();
        foreach ($tmp as $v) {
            extract($v);
            $clean_urls[$resource_type][$resource_id] = str_replace('.', '-', $clean_url);
        }
    } else {
        $tmp = cw_query("Select 'C' as type, categoryid as id, LCASE(category) as name from xcart_categories\n\t\t\tunion Select 'P' as type, productid as id, LCASE(product) as name from xcart_products\n\t\t\tunion Select 'M' as type, manufacturerid as id, LCASE(manufacturer) as name from xcart_manufacturers", $conn);
        $clean_urls = array();
        $curls = array();
        foreach ($tmp as $v) {
            extract($v);
            $cu = preg_replace("'[^a-z0-9]+'s", ' ', $name);
            $cu = str_replace(' ', '-', $cu);
            $i = 1;
            $curl = $cu;
            while (in_array($curl, $curls)) {
                $curl = $cu . '-' . $i++;
            }
            $clean_urls[$type][$id] = $curl;
            $curls[] = $curl;
        }
        unset($curls);
    }
    unset($tmp);
    if ($pwithmeta) {
        $prodmeta = cw_query("Select productid as id, 'P' as type, product, manufacturerid,\n\t\t  meta_description, meta_keywords, title_tag, add_date from xcart_products", $conn);
    } else {
        $prodmeta = cw_query("Select productid as id, 'P' as type, product, descr,\n\t\t\tmanufacturerid, add_date from xcart_products", $conn);
        foreach ($prodmeta as $k => $v) {
            extract($v);
            $prodmeta[$k]['title_tag'] = trim($product);
            $descr = preg_replace("'</?[a-z]+.*?>'is", " ", $descr);
            $descr = trim(preg_replace("'\\s+'", " ", $descr));
            $prodmeta[$k]['meta_description'] = $descr;
            $mk = preg_replace("'[^a-z]+'is", " ", $product);
            $prodmeta[$k]['meta_keywords'] = str_replace(' ', ', ', trim($mk));
        }
    }
    db_query("TRUNCATE TABLE cw_products_system_info");
    $admin = cw_query_first_cell("select customer_id from cw_customers where usertype='A' limit 1");
    foreach ($prodmeta as $v) {
        extract($v);
        cw_set_attr($type, 'domains', $id, 0);
        cw_set_attr($type, 'meta_title', $id, $title_tag);
        cw_set_attr($type, 'meta_keywords', $id, $meta_keywords);
        cw_set_attr($type, 'meta_description', $id, $meta_description);
        if (isset($clean_urls[$type]) && isset($clean_urls[$type][$id])) {
            cw_set_attr($type, 'clean_url', $id, $clean_urls[$type][$id]);
        }
        cw_set_attr($type, 'manufacturer_id', $id, $manufacturerid);
        $product_id = $id;
        $creation_customer_id = $modification_customer_id = $admin;
        $creation_date = $modification_date = $add_date;
        cw_array2insert('cw_products_system_info', compact('product_id', 'creation_customer_id', 'creation_date', 'modification_customer_id', 'modification_date'));
    }
    if ($cwithmeta) {
        $catmeta = cw_query("Select categoryid as id, 'C' as type, category,\n\t\t  meta_description, meta_keywords, title_tag from xcart_categories", $conn);
    } else {
        foreach ($cats as $k => $v) {
            extract($v);
            $catmeta[$k]['title_tag'] = trim($category);
            $descr = preg_replace("'</?[a-z]+.*?>'is", " ", $description);
            $descr = trim(preg_replace("'\\s+'", " ", $descr));
            $catmeta[$k]['meta_description'] = $descr;
            $mk = preg_replace("'[^a-z]+'is", " ", $category);
            $catmeta[$k]['meta_keywords'] = str_replace(' ', ', ', trim($mk));
            $catmeta[$k]['type'] = 'C';
            $catmeta[$k]['id'] = $category_id;
        }
    }
    foreach ($catmeta as $v) {
        extract($v);
        cw_set_attr($type, 'domains', $id, 0);
        cw_set_attr($type, 'meta_title', $id, $title_tag);
        cw_set_attr($type, 'meta_keywords', $id, $meta_keywords);
        cw_set_attr($type, 'meta_description', $id, $meta_description);
        if (isset($clean_urls[$type]) && isset($clean_urls[$type][$id])) {
            cw_set_attr($type, 'clean_url', $id, $clean_urls[$type][$id]);
        }
    }
    if ($cwithmeta) {
        $manmeta = cw_query("Select manufacturerid as id, 'M' as type, manufacturer,\n\t\t  meta_description, meta_keywords, title_tag from xcart_manufacturers", $conn);
    } else {
        foreach ($mans as $k => $v) {
            extract($v);
            $manmeta[$k]['title_tag'] = trim($manufacturer);
            $descr = preg_replace("'</?[a-z]+.*?>'is", " ", $descr);
            $descr = trim(preg_replace("'\\s+'", " ", $descr));
            $manmeta[$k]['meta_description'] = $descr;
            $mk = preg_replace("'[^a-z]+'is", " ", $manufacturer);
            $manmeta[$k]['meta_keywords'] = str_replace(' ', ', ', trim($mk));
            $manmeta[$k]['type'] = 'M';
            $manmeta[$k]['id'] = $manufacturer_id;
        }
    }
    if (is_array($manmeta)) {
        foreach ($manmeta as $v) {
            extract($v);
            cw_set_attr($type, 'domains', $id, 0);
            cw_set_attr($type, 'meta_title', $id, $title_tag);
            cw_set_attr($type, 'meta_keywords', $id, $meta_keywords);
            cw_set_attr($type, 'meta_description', $id, $meta_description);
            if (isset($clean_urls[$type]) && isset($clean_urls[$type][$id])) {
                cw_set_attr($type, 'clean_url', $id, $clean_urls[$type][$id]);
            }
        }
    }
    // Grab categories, products (Thumbnails & Detailed), and manufacturers related Images
    cw_imgs_copy($xcart_conf, 'xcart_images_C', 'cw_categories_images_thumb', 'categories_images_thumb');
    cw_imgs_copy($xcart_conf, 'xcart_images_T', 'cw_products_images_thumb', 'products_images_thumb', 70);
    cw_imgs_copy($xcart_conf, 'xcart_images_P', 'cw_products_images_det', 'products_images_det');
    cw_imgs_copy($xcart_conf, 'xcart_images_D', 'cw_products_detailed_images', 'products_detailed_images', 800);
    cw_imgs_copy($xcart_conf, 'xcart_images_M', 'cw_manufacturer_images', 'manufacturer_images', 150);
    // Variants -- Classes
    cw_table_copy_from_xcart_comm($conn, 'xcart_variants', 'cw_product_variants', "variantid as variant_id, productid as product_id, concat(productcode,variantid) as eancode");
    cw_table_copy_from_xcart_lit($conn, 'xcart_variant_items', 'cw_product_variant_items', "optionid as option_id, variantid as variant_id");
    // Variants -- available in stock -- adding to cw_products_warehouses_amount,
    // where we alredy have 'avail' field for variants equal 0 (for prods without variants)
    $var_prod_avail = cw_query("Select variantid as variant_id, productid as product_id, avail from xcart_variants", $conn);
    foreach ($var_prod_avail as $v) {
        cw_array2insert('cw_products_warehouses_amount', $v);
    }
    cw_table_copy_from_xcart_comm($conn, 'xcart_classes', 'cw_product_options', "classid as product_option_id, class as field,\n\t\tclasstext as name, productid as product_id, if(avail='Y',1,0) as avail, is_modifier as type");
    cw_table_copy_from_xcart_comm($conn, 'xcart_class_options', 'cw_product_options_values', "classid as product_option_id, option_name as name, if(avail='Y',1,0) as avail,\n\t\t    optionid as option_id, if(modifier_type='\$',0,1) as modifier_type");
    cw_table_copy_from_xcart_lit($conn, 'xcart_class_lng', 'cw_product_options_lng', "UPPER(code) as code, classid as product_option_id, classtext as name");
    db_query("TRUNCATE TABLE cw_product_options_values_lng");
    db_query("TRUNCATE TABLE cw_customers_warehouses");
    // Product Links ---
    cw_table_copy_from_xcart_comm($conn, 'xcart_product_links', 'cw_linked_products', "productid1 as product_id, productid2 as linked_product_id, 1 as active");
    // Featured Products
    cw_table_copy_from_xcart_lit_sn($conn, 'featured_products', "productid as product_id, 0 as category_id,\n\t\tproduct_order, if(avail='Y',1,0) as avail");
    // Product review, ratings
    cw_table_copy_from_xcart_comm($conn, 'xcart_product_reviews', 'cw_products_reviews', "productid as product_id");
    cw_table_copy_from_xcart_comm($conn, 'xcart_product_votes', 'cw_products_votes', "productid as product_id, vote_value/20 as vote_value");
    // Taxes, tax rates
    cw_table_copy_from_xcart_comm_sn($conn, 'taxes', "taxid as tax_id, if(active='Y',1,0) as active,\n\t\t  if(price_includes_tax='Y',1,0) as price_includes_tax, if(display_including_tax='Y',1,0) as display_including_tax");
    cw_table_copy_from_xcart_comm_sn($conn, 'tax_rates', "rateid as rate_id, taxid as tax_id, zoneid as zone_id,\n\t\t  0 as wherehouse_customer_id");
    db_query("DELETE from cw_languages_alt where name rlike '^tax\\_[0-9]+\$'");
    cw_import_config($conn);
    // Menu -- Make top categories featured -- and add 8 top categories (with subcategories) to Top Menu
    db_query("Update cw_categories set featured=1 where parent_id=0 and status=1");
    db_query("Update cw_categories set tm_active=1 where parent_id!=0");
    $ids = cw_query_first_cell("select group_concat(category_id) as cids from\n\t\t(select category_id from cw_categories where parent_id=0 and status=1 order by order_by limit 8) cat");
    db_query("Update cw_categories set tm_active=1 where category_id in ({$ids})");
    cw_cat_tree_building();
    db_query("TRUNCATE TABLE cw_categories_subcount");
    cw_recalc_subcat_count(0);
}
        }
    }
    if (!in_array($cat_location, $cat_ids)) {
        foreach ($cat_ids as $id) {
            // Get all affected categories - parent and children
            $parent_id = cw_query_first_cell("select parent_id from {$tables['categories']} where category_id='{$id}'");
            $subcats = cw_category_get_subcategory_ids($id);
            db_query("update {$tables['categories']} set parent_id='{$cat_location}' where category_id='{$id}'");
            cw_category_update_path($id);
            if (count($subcats)) {
                foreach ($subcats as $scat_id) {
                    cw_category_update_path($scat_id);
                }
            }
            $path = array($parent_id, $cat_location);
            cw_recalc_subcat_count($path);
        }
        $top_message = array('content' => cw_get_langvar_by_name('msg_adm_category_move'), 'type' => 'I');
        cw_header_location("index.php?target={$target}&mode=edit&cat={$cat}&ge_id={$ge_id}");
    }
}
if ($action == "delete_icon" && !empty($cat)) {
    cw_image_delete($cat, 'categories_images_thumb');
    if ($ge_id && $fields['image']) {
        while ($id = cw_group_edit_each($ge_id, 100, $cat)) {
            cw_image_delete($id, 'categories_images_thumb');
        }
    }
    $top_message = array('content' => cw_get_langvar_by_name('msg_adm_category_icon_del'), 'type' => 'I');
    cw_header_location("index.php?target={$target}&mode={$mode}&cat={$cat}&ge_id={$ge_id}");
}
function cw_user_delete_memberships($del)
{
    global $tables;
    if (!is_array($del)) {
        $del[] = $del;
    }
    if (!count($del)) {
        return;
    }
    $delete_string = "membership_id IN ('" . implode("','", $del) . "')";
    if (cw_query_first_cell("SELECT COUNT(*) FROM {$tables['memberships']} WHERE area IN ('C', 'R') AND " . $delete_string)) {
        $recalc_subcat_count = true;
    }
    db_query("DELETE FROM {$tables['memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['super_deals']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['categories_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['products_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['tax_rate_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['memberships_lng']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['payment_methods_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['discounts_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['access_levels']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['newslists_memberships']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['products_prices']} WHERE " . $delete_string);
    db_query("DELETE FROM {$tables['tax_rate_memberships']} WHERE " . $delete_string);
    foreach ($del as $id) {
        // TODO: move to addon
        global $addons;
        if ($addons['faq']) {
            cw_load('faq');
            cw_faq_delete_membership($id);
        }
        db_query("DELETE FROM {$tables['register_fields_avails']} WHERE area LIKE '%_{$id}'");
    }
    cw_array2update("customers", array("membership_id" => 0), $delete_string);
    if ($recalc_subcat_count) {
        cw_load('category');
        cw_recalc_subcat_count(0, 100);
    }
}
    $cat_id = $cat_ids[0];
    cw_header_location('index.php?target=' . $target . '&mode=edit&cat=' . $cat_id . '&ge_id=' . $ge_id);
}
if ($action == 'apply' && is_array($posted_data)) {
    foreach ($posted_data as $k => $v) {
        $query_data = array('order_by' => intval($v['order_by']));
        cw_array2update('categories', $query_data, "category_id='" . $k . "'");
        cw_category_update_status($k, $v['status']);
    }
    if ($cat) {
        $path = cw_category_get_subcategory_ids($cat);
        if (!empty($path)) {
            cw_recalc_subcat_count($path);
        }
    } else {
        cw_recalc_subcat_count();
    }
    $top_message = array('content' => cw_get_langvar_by_name('msg_adm_categories_upd'), 'type' => 'I');
    cw_header_location("index.php?target={$target}" . ($mode ? '&mode=' . $mode : '') . "&cat={$cat}&js_tab={$js_tab}");
}
if ($action == 'delete') {
    if ($confirmed == "Y") {
        # kronev, for the big amount of products - the
        cw_display_service_header('lbl_delete_categories') . '<br/>';
        if (is_array($categories_to_delete)) {
            foreach ($categories_to_delete as $cat) {
                $parent_category_id = cw_call('cw_category_delete', array($cat, true));
            }
        }
        $top_message = array('content' => cw_get_langvar_by_name('msg_adm_category_del'), 'type' => 'I');
        cw_header_location('index.php?target=categories&cat=' . $parent_category_id);
    }
    cw_header_location("index.php?target={$target}");
}
if ($action == 'add' && !empty($add['membership'])) {
    if (empty($add['orderby'])) {
        $add['orderby'] = cw_query_first_cell("SELECT MAX(orderby) FROM {$tables['memberships']} WHERE area = '{$add['area']}'") + 1;
    }
    $add['active'] = $add['active'];
    $id = cw_array2insert("memberships", $add);
    if ($addons['faq']) {
        cw_faq_create_membership($id);
    }
    db_query("INSERT INTO {$tables['memberships_lng']} VALUES ('{$id}','{$edited_language}','{$add['membership']}')");
    if ($add['area'] == 'C' || $add['area'] == 'R') {
        cw_load("category");
        cw_recalc_subcat_count(0, 100);
    }
    // Copy default fields setting for new membership
    db_query("INSERT INTO {$tables['register_fields_avails']} ( `field_id` , `area` , `is_avail` , `is_required` ) (\n    SELECT field_id, CONCAT(area, '_{$id}' ) , is_avail, is_required\n    FROM {$tables['register_fields_avails']}\n    WHERE area IN ('{$add['area']}', '#{$add['area']}')\n    )");
    cw_header_location("index.php?target={$target}");
}
if ($action == 'delete' && !empty($to_delete)) {
    cw_call('cw_user_delete_memberships', array($to_delete));
    cw_header_location("index.php?target={$target}");
}
$memberships = array();
$memberships['A'] = array();
$memberships['C'] = array();
$memberships['V'] = array();
$tmp = cw_query("SELECT {$tables['memberships']}.*, COUNT({$tables['customers']}.customer_id) as users, IFNULL({$tables['memberships_lng']}.membership, {$tables['memberships']}.membership) as membership FROM {$tables['memberships']} LEFT JOIN {$tables['customers']} ON {$tables['customers']}.membership_id = {$tables['memberships']}.membership_id LEFT JOIN {$tables['memberships_lng']} ON {$tables['memberships']}.membership_id = {$tables['memberships_lng']}.membership_id AND {$tables['memberships_lng']}.code = '{$edited_language}' GROUP BY {$tables['memberships']}.membership_id ORDER BY IF(FIELD({$tables['memberships']}.area, 'A','P','C','R','B','V') > 0, FIELD({$tables['memberships']}.area, 'A','P','C','R','B','V'), 100), {$tables['memberships']}.orderby");
if (!empty($tmp)) {
function cw_product_clone($product_id)
{
    global $addons, $customer_id, $tables;
    $tables_array = array(array('table' => 'products_images_thumb', 'key_field' => 'id'), array('table' => 'products_images_det', 'key_field' => 'id'), array('table' => 'delivery', 'key_field' => 'product_id'), array('table' => 'attributes_values', 'key_field' => 'item_id'), array('table' => 'products_lng', 'key_field' => 'product_id'), array('table' => 'products_categories', 'key_field' => 'product_id'), array('table' => 'products_memberships', 'key_field' => 'product_id'));
    $product_data = cw_query_first("SELECT * FROM {$tables['products']} WHERE product_id='{$product_id}'");
    if (!$product_data) {
        return;
    }
    $product_data['productcode'] = cw_product_generate_sku();
    $new_product_id = cw_array2insert('products', array('productcode' => $product_data['productcode'], 'product_type' => $product_data['product_type']));
    $to_update = array();
    foreach ($product_data as $field => $value) {
        if (!in_array($field, array('product_id', 'productcode', 'product_type', 'views_stats'))) {
            $to_update[] = $field;
        }
    }
    $product_data['product'] = $product_data['product'] . ' (CLONE)';
    cw_array2update('products', cw_addslashes($product_data), "product_id='{$new_product_id}'", $to_update);
    foreach ($tables_array as $k => $v) {
        $error_string .= cw_core_copy_tables($v['table'], $v['key_field'], $product_id, $new_product_id);
    }
    db_query("update {$tables['products_lng']} set product = concat(product, ' (CLONE)') where product_id='{$new_product_id}'");
    // Clone prices
    $prices = cw_query("SELECT * FROM {$tables['products_prices']} WHERE product_id = '{$product_id}' AND variant_id = '0'");
    if (!empty($prices)) {
        foreach ($prices as $v) {
            unset($v['price_id']);
            $v['product_id'] = $new_product_id;
            cw_array2insert('products_prices', $v);
        }
    }
    $prices = cw_query("select pp.* from {$tables['products_prices']} as pp where pp.product_id='{$product_id}'");
    cw_func_call('cw_product_build_flat', array('product_id' => $new_product_id));
    cw_product_update_system_info($new_product_id, $customer_id);
    //    cw_warehouse_recalculate($product_id);
    // Update products counter for categories in which product is placed
    $product_categorie = cw_query_first("SELECT category_id FROM {$tables['products_categories']} WHERE product_id = '{$product_id}'");
    cw_recalc_subcat_count($product_categorie['category_id']);
    return $new_product_id;
}
function cw_category_check_disabled_parents($category_id)
{
    global $tables;
    $path = cw_category_get_path($category_id);
    cw_recalc_subcat_count($path);
    if (is_array($path)) {
        foreach ($path as $v) {
            if ($v && $v != $category_id) {
                $is_parent_avail = cw_query_first_cell("select status from {$tables['categories']} where category_id='{$v}'");
                if (!$is_parent_avail) {
                    cw_category_disable_subcategories($v);
                }
            }
        }
    }
}
 }
 if (!empty($fields)) {
     $do_not_update = array('price', 'thumbnail', 'product_image', 'category_id', 'category_ids', 'membership_ids');
     $to_update = array_intersect($query_fields, array_keys($fields));
     $to_update = array_intersect($to_update, array_diff($to_update, $do_not_update));
     if (count($to_update)) {
         cw_group_edit_copy($ge_id, 'products', 'product_id', $product_id, $to_update);
     }
 }
 if ($config['Appearance']['categories_in_products'] == '1') {
     cw_recalc_subcat_count($category_id);
     if (is_array($old_product_categories)) {
         $category_ids = cw_array_merge($old_product_categories, $category_ids);
     }
     $category_ids = cw_array_merge($category_ids, $product_data['category_ids'], array($category_id));
     cw_recalc_subcat_count(cw_category_get_path($category_ids));
 }
 if ($is_new_product) {
     cw_add_top_message(cw_get_langvar_by_name('msg_adm_product_add'));
 } else {
     cw_add_top_message(cw_get_langvar_by_name("msg_adm_product_upd"));
 }
 if (!$is_variant) {
     //cw_price_lists_replace_price($product_id, $product_data['price'], 0, $is_new_product, $product_data['is_manual_price']);
     if (isset($product_data['price']) && isset($product_data['list_price'])) {
         cw_product_update_price($product_id, 0, 0, 0, 1, 1, $product_data['price'], $product_data['list_price']);
     }
 }
 if ($fields['price'] && !$is_variant) {
     if ($ge_id) {
         while ($pid = cw_group_edit_each($ge_id, 1, $product_id)) {