function cw_group_edit_update_category($ge_id, $cat, $fields, $data)
{
    if (!$ge_id || !$cat || !count($fields)) {
        return;
    }
    global $tables, $config, $edited_language;
    $query_fields = cw_query_column("desc {$tables['categories']}", 'Field');
    $to_update = array_intersect($query_fields, array_keys($fields));
    # kornev, add attributes to update
    if ($edited_language != $config['default_admin_language']) {
        cw_unset($to_update, 'category', 'description');
    }
    if ($to_update) {
        cw_group_edit_copy($ge_id, 'categories', 'category_id', $cat, $to_update);
    }
    if ($fields['membership_ids']) {
        while ($id = cw_group_edit_each($ge_id, 1, $cat)) {
            cw_membership_update('categories', $id, $data['membership_ids'], 'category_id');
        }
    }
    if ($fields['avail']) {
        while ($id = cw_group_edit_each($ge_id, 1, $cat)) {
            cw_category_update_status($id, $data['avail']);
        }
    }
    if ($fields['category'] || $fields['description']) {
        $to_update = array_intersect(array('category', 'description'), array_keys($fields));
        cw_group_edit_copy($ge_id, 'categories_lng', 'category_id', $cat, $to_update, "code='{$edited_language}'");
    }
    if ($fields['image']) {
        cw_group_edit_copy($ge_id, 'categories_images_thumb', 'id', $cat);
    }
    cw_attributes_group_update($ge_id, $cat, 'C', $fields);
}
             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)) {
                 if ($pid != $product_id) {
                     cw_price_lists_replace_price($pid, $product_data['price'], 0);
                 }
             }
         }
     }
     cw_func_call('cw_items_attribute_classes_save', array('item_id' => $product_id, 'attribute_class_ids' => $product_data['attribute_class_ids'], 'item_type' => 'P'));
     # kornev, it have to be product_data here - because we change the attributes in the error_check function
     cw_call('cw_attributes_save', array('item_id' => $product_id, 'item_type' => 'P', 'attributes' => $product_data['attributes'], 'language' => $edited_language, array('update_posted_only' => true, 'is_default' => false)));
     cw_attributes_group_update($ge_id, $product_id, 'P', $fields);
     cw_func_call('cw_product_build_flat', array('product_id' => $product_id));
     cw_group_edit_end($product_id);
     cw_product_update_system_info($product_id, array('supplier_customer_id' => $product_data['supplier']));
     cw_group_edit_copy_system_info($product_id, array('supplier_customer_id' => $product_data['supplier']));
     cw_warehouse_recalculate($product_id);
     cw_product_filter_recalculate_price_ranges();
     // tags
     if (!empty($product_data['tags'])) {
         $tags = explode(',', $product_data['tags']);
         cw_tags_set_product_tags($tags, $product_id);
     } else {
         cw_tags_clear_product_tags($product_id);
     }
 } else {
     cw_add_top_message($fillerror, 'E');