コード例 #1
0
ファイル: specials.php プロジェクト: ygeneration666/ec
function zen_start_specials()
{
    global $db;
    $date_range = time();
    $zc_specials_date = date('Ymd', $date_range);
    // turn on special if active
    $specials_query = "select specials_id, products_id\r\n                       from " . TABLE_SPECIALS . "\r\n                       where status = '0'\r\n                       and (((specials_date_available <= " . $zc_specials_date . " and specials_date_available != '0001-01-01') and (expires_date > " . $zc_specials_date . "))\r\n                       or ((specials_date_available <= " . $zc_specials_date . " and specials_date_available != '0001-01-01') and (expires_date = '0001-01-01'))\r\n                       or (specials_date_available = '0001-01-01' and expires_date > " . $zc_specials_date . "))\r\n                       ";
    $specials = $db->Execute($specials_query);
    if ($specials->RecordCount() > 0) {
        while (!$specials->EOF) {
            zen_set_specials_status($specials->fields['specials_id'], '1');
            zen_update_products_price_sorter($specials->fields['products_id']);
            $specials->MoveNext();
        }
    }
    // turn off special if not active yet
    $specials_query = "select specials_id, products_id\r\n                       from " . TABLE_SPECIALS . "\r\n                       where status = '1'\r\n                       and (" . $zc_specials_date . " < specials_date_available and specials_date_available != '0001-01-01')\r\n                       ";
    $specials = $db->Execute($specials_query);
    if ($specials->RecordCount() > 0) {
        while (!$specials->EOF) {
            zen_set_specials_status($specials->fields['specials_id'], '0');
            zen_update_products_price_sorter($specials->fields['products_id']);
            $specials->MoveNext();
        }
    }
}
コード例 #2
0
             // changed INSERT INTO to UPDATE to prevent conflicts
             $db->Execute("UPDATE " . TABLE_PRODUCTS_TO_CATEGORIES . " SET categories_id='" . (int) $new_value . "', products_id=" . (int) $products_id . " WHERE products_id=" . (int) $products_id . " AND categories_id=" . (int) $_POST['quick_updates_old']['categories_id'][$products_id]);
         }
     }
 }
 if ($_POST['quick_updates_new']['master_categories_id']) {
     foreach ($_POST['quick_updates_new']['master_categories_id'] as $products_id => $new_value) {
         if ($_POST['quick_updates_new']['master_categories_id'][$products_id] != $_POST['quick_updates_old']['master_categories_id'][$products_id]) {
             if (zen_childs_in_category_count($new_value)) {
                 $messageStack->add(TEXT_CATEGORY_WITH_CHILDS . ' ' . zen_get_category_name($new_value, (int) $_SESSION["languages_id"]) . ' [' . $new_value . ']', 'error');
                 continue;
             }
             // add invalid warning here?? (if the new master_cat is not linked)
             $quick_updates_count['master_categories_id'][$products_id] = $products_id;
             $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . (int) $new_value . "', products_last_modified=now() WHERE products_id=" . (int) $products_id);
             zen_update_products_price_sorter((int) $products_id);
             // needed?
         }
     }
 }
 // added for products_purchase_price and margin
 if ($_POST['quick_updates_new']['products_purchase_price']) {
     foreach ($_POST['quick_updates_new']['products_purchase_price'] as $products_id => $new_value) {
         if ($_POST['quick_updates_new']['products_purchase_price'][$products_id] != $_POST['quick_updates_old']['products_purchase_price'][$products_id]) {
             $quick_updates_count['products_purchase_price'][$products_id] = $products_id;
             $db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_purchase_price='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int) $products_id);
         }
     }
 }
 // added for products_purchase_price and margin
 if ($_POST['quick_updates_new']['products_margin']) {
コード例 #3
0
     }
     break;
     // @@TODO where is move_product_confirm
     // @@TODO where is insert_product
     // @@TODO where is update_product
     // attribute features
 // @@TODO where is move_product_confirm
 // @@TODO where is insert_product
 // @@TODO where is update_product
 // attribute features
 case 'delete_attributes':
     zen_delete_products_attributes($_GET['products_id']);
     $messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED . ' ID#' . $_GET['products_id'], 'success');
     $action = '';
     // reset products_price_sorter for searches etc.
     zen_update_products_price_sorter($_GET['products_id']);
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
     break;
 case 'update_attributes_sort_order':
     zen_update_attributes_products_option_values_sort_order($_GET['products_id']);
     $messageStack->add_session(SUCCESS_ATTRIBUTES_UPDATE . ' ID#' . $_GET['products_id'], 'success');
     $action = '';
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['products_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
     break;
     // attributes copy to product
 // attributes copy to product
 case 'update_attributes_copy_to_product':
     $copy_attributes_delete_first = $_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0';
     $copy_attributes_duplicates_skipped = $_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0';
     $copy_attributes_duplicates_overwrite = $_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0';
     zen_copy_products_attributes($_POST['products_id'], $_POST['products_update_id']);
コード例 #4
0
     zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_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'] . "'");
         $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 . '&current_category_id=' . $_POST['current_category_id']));
     break;
     // attributes copy to product
 // attributes copy to product
 case 'update_attributes_copy_to_product':
     $copy_attributes_delete_first = $_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0';
     $copy_attributes_duplicates_skipped = $_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0';
     $copy_attributes_duplicates_overwrite = $_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0';
     zen_copy_products_attributes($_POST['products_filter'], $_POST['products_update_id']);
     $_GET['action'] = '';
     $products_filter = $_POST['products_update_id'];
     zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_POST['current_category_id']));
     break;
     // attributes copy to category
 // attributes copy to category
コード例 #5
0
ファイル: quick_copy.php プロジェクト: dalinhuang/cameras
function quick_copy_product($products_id, $categories_id = '')
{
    global $db;
    if (!(isset($products_id) && isset($categories_id))) {
        return FALSE;
    }
    // ??
    $products_id = (int) $products_id;
    // copy from this product (to a new product)
    //$categories_id = zen_db_prepare_input($categories_id); // copy to this catagory
    //if(!($products_id > 0)) return false;
    if (!zen_products_id_valid($products_id)) {
        exit('Fatal error: attempt to copy invalid product by quick_copy (products_id = ' . $products_id . ')');
    }
    // Copy attributes to duplicate product
    $products_id_from = $products_id;
    // bof duplicate
    $old_products_id = (int) $products_id;
    $product = $db->Execute("select products_type, products_quantity, products_model, products_image,\r\n                                  products_price, products_virtual, products_date_available, products_weight,\r\n                                  products_tax_class_id, manufacturers_id,\r\n                                  products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,\r\n                                  product_is_free, product_is_call, products_quantity_mixed,\r\n                                  product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,\r\n                                  products_price_sorter, master_categories_id\r\n                           from " . TABLE_PRODUCTS . "\r\n                           where products_id = '" . (int) $products_id . "'");
    // bof replace product data by nimport product data (+ add purchase price)
    // eof replace product data by nimport product data
    $tmp_value = zen_db_input($product->fields['products_quantity']);
    $products_quantity = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value;
    $tmp_value = zen_db_input($product->fields['products_price']);
    $products_price = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value;
    $tmp_value = zen_db_input($product->fields['products_weight']);
    $products_weight = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value;
    // check if categorie has products!?
    if (!$categories_id >= 0) {
        $categories_id = $product->fields['master_categories_id'];
    }
    $db->Execute("insert into " . TABLE_PRODUCTS . "\r\n                                      (products_type, products_quantity, products_model, products_image,\r\n                                       products_price, products_virtual, products_date_added, products_date_available,\r\n                                       products_weight, products_status, products_tax_class_id,\r\n                                       manufacturers_id,\r\n                                       products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,\r\n                                       product_is_free, product_is_call, products_quantity_mixed,\r\n                                       product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,\r\n                                       products_price_sorter, master_categories_id\r\n                                       )\r\n                          values ('" . zen_db_input($product->fields['products_type']) . "',\r\n                                  '" . $products_quantity . "',\r\n                                  '" . zen_db_input($product->fields['products_model']) . "',\r\n                                  '" . zen_db_input($product->fields['products_image']) . "',\r\n                                  '" . $products_price . "',\r\n                                  '" . zen_db_input($product->fields['products_virtual']) . "',\r\n                                  now(),\r\n                                  '" . zen_db_input($product->fields['products_date_available']) . "',\r\n                                  '" . $products_weight . "', '0',\r\n                                  '" . (int) $product->fields['products_tax_class_id'] . "',\r\n                                  '" . (int) $product->fields['manufacturers_id'] . "',\r\n                                  '" . zen_db_input($product->fields['products_quantity_order_min']) . "',\r\n                                  '" . zen_db_input($product->fields['products_quantity_order_units']) . "',\r\n                                  '" . zen_db_input($product->fields['products_priced_by_attribute']) . "',\r\n                                  '" . (int) $product->fields['product_is_free'] . "',\r\n                                  '" . (int) $product->fields['product_is_call'] . "',\r\n                                  '" . (int) $product->fields['products_quantity_mixed'] . "',\r\n                                  '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "',\r\n                                  '" . zen_db_input($product->fields['products_qty_box_status']) . "',\r\n                                  '" . zen_db_input($product->fields['products_quantity_order_max']) . "',\r\n                                  '" . zen_db_input($product->fields['products_sort_order']) . "',\r\n                                  '" . zen_db_input($product->fields['products_price_sorter']) . "',\r\n                                  '" . (int) $categories_id . "')");
    $dup_products_id = $db->Insert_ID();
    $description = $db->Execute("select language_id, products_name, products_description, products_url\r\n                               from " . TABLE_PRODUCTS_DESCRIPTION . "\r\n                               where products_id = '" . (int) $products_id . "'");
    while (!$description->EOF) {
        $db->Execute("insert into " . TABLE_PRODUCTS_DESCRIPTION . "\r\n                     (products_id, language_id, products_name, products_description, products_url, products_viewed)\r\n                     values ('" . (int) $dup_products_id . "',\r\n                             '" . (int) $description->fields['language_id'] . "',\r\n                             '" . zen_db_input($description->fields['products_name']) . "',\r\n                             '" . zen_db_input($description->fields['products_description']) . "',\r\n                             '" . zen_db_input($description->fields['products_url']) . "', '0')");
        $description->MoveNext();
    }
    $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n              (products_id, categories_id)\r\n               values ('" . (int) $dup_products_id . "', '" . (int) $categories_id . "')");
    $products_id = $dup_products_id;
    $description->MoveNext();
    // FIX HERE
    /////////////////////////////////////////////////////////////////////////////////////////////
    // Copy attributes to duplicate product
    $products_id_to = $dup_products_id;
    $products_id = $dup_products_id;
    /*
    if ( $_POST['copy_attributes']=='copy_attributes_yes' and $_POST['copy_as'] == 'duplicate' ) {
      // $products_id_to= $copy_to_products_id;
    //            $copy_attributes_delete_first='1';
    //            $copy_attributes_duplicates_skipped='1';
    //            $copy_attributes_duplicates_overwrite='0';
    
                if (DOWNLOAD_ENABLED == 'true') {
                  $copy_attributes_include_downloads='1';
                  $copy_attributes_include_filename='1';
                } else {
                  $copy_attributes_include_downloads='0';
                  $copy_attributes_include_filename='0';
                }
    
                zen_copy_products_attributes($products_id_from, $products_id_to);
    }
    */
    // EOF: Attributes Copy on non-linked
    /////////////////////////////////////////////////////////////////////
    // copy product discounts to duplicate
    zen_copy_discounts_to_product($old_products_id, (int) $dup_products_id);
    // eof duplicate
    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter($products_id);
    //zen_redirect(zen_href_link(FILENAME_QUICK_COPY, 'cPath=' . $categories_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
    // succes
    $copy['products_id'] = (int) $dup_products_id;
    $copy['master_categories_id'] = (int) $categories_id;
    return $copy;
}
コード例 #6
0
ファイル: copy_to_confirm.php プロジェクト: ZenMagick/zc-base
        /////////////////////////////////////////////////////////////////////////////////////////////
        // Copy attributes to duplicate product
        // moved above            $products_id_from=zen_db_input($products_id);
        $products_id_to = $dup_products_id;
        $products_id = $dup_products_id;
        if ($_POST['copy_attributes'] == 'copy_attributes_yes' and $_POST['copy_as'] == 'duplicate') {
            // $products_id_to= $copy_to_products_id;
            // $products_id_from = $pID;
            //            $copy_attributes_delete_first='1';
            //            $copy_attributes_duplicates_skipped='1';
            //            $copy_attributes_duplicates_overwrite='0';
            if (DOWNLOAD_ENABLED == 'true') {
                $copy_attributes_include_downloads = '1';
                $copy_attributes_include_filename = '1';
            } else {
                $copy_attributes_include_downloads = '0';
                $copy_attributes_include_filename = '0';
            }
            zen_copy_products_attributes($products_id_from, $products_id_to);
        }
        // EOF: Attributes Copy on non-linked
        /////////////////////////////////////////////////////////////////////
        // copy product discounts to duplicate
        if ($_POST['copy_discounts'] == 'copy_discounts_yes') {
            zen_copy_discounts_to_product($old_products_id, (int) $dup_products_id);
        }
    }
    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter($products_id);
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
コード例 #7
0
function zen_update_salemaker_product_prices($salemaker_id)
{
    global $db;
    $zv_categories = $db->Execute("select sale_categories_selected from " . TABLE_SALEMAKER_SALES . " where sale_id = '" . $salemaker_id . "'");
    $za_salemaker_categories = zen_parse_salemaker_categories($zv_categories->fields['sale_categories_selected']);
    $n = sizeof($za_salemaker_categories);
    for ($i = 0; $i < $n; $i++) {
        $update_products_price = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $za_salemaker_categories[$i] . "'");
        while (!$update_products_price->EOF) {
            zen_update_products_price_sorter($update_products_price->fields['products_id']);
            $update_products_price->MoveNext();
        }
    }
}
コード例 #8
0
ファイル: store_manager.php プロジェクト: dalinhuang/cameras
     while (!$all_products_attributes->EOF) {
         $count++;
         $product_id_updated .= ' - ' . $all_products_attributes->fields['products_id'] . ':' . $all_products_attributes->fields['products_attributes_id'];
         zen_update_attributes_products_option_values_sort_order($all_products_attributes->fields['products_id']);
         $all_products_attributes->MoveNext();
     }
     $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_SORT_ALL, 'success');
     $action = '';
     zen_redirect(zen_href_link(FILENAME_STORE_MANAGER));
     break;
 case 'update_all_products_price_sorter':
     // reset products_price_sorter for searches etc.
     $sql = "select products_id from " . TABLE_PRODUCTS;
     $update_prices = $db->Execute($sql);
     while (!$update_prices->EOF) {
         zen_update_products_price_sorter($update_prices->fields['products_id']);
         $update_prices->MoveNext();
     }
     $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_PRODUCTS_PRICE_SORTER, 'success');
     $action = '';
     zen_redirect(zen_href_link(FILENAME_STORE_MANAGER));
     break;
 case 'update_all_products_viewed':
     // reset products_viewed to 0
     $sql = "update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed= '0'";
     $update_viewed = $db->Execute($sql);
     $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_PRODUCTS_VIEWED, 'success');
     $action = '';
     zen_redirect(zen_href_link(FILENAME_STORE_MANAGER));
     break;
 case 'update_all_products_ordered':
コード例 #9
0
ファイル: DbIoProductsHandler.php プロジェクト: lat9/dbio
 protected function importRecordPostProcess($products_id)
 {
     $this->debugMessage('Products::importRecordPostProcess: ' . $this->data_key_sql . "\n" . print_r($this->key_fields, true), self::DBIO_INFORMATIONAL);
     if ($products_id !== false && $this->operation != 'check') {
         zen_update_products_price_sorter($products_id);
     }
 }
コード例 #10
0
function ep_update_prices()
{
    global $db;
    // reset products_price_sorter for searches etc.
    $sql = "select products_id from " . TABLE_PRODUCTS;
    $update_prices = $db->Execute($sql);
    while (!$update_prices->EOF) {
        zen_update_products_price_sorter($update_prices->fields['products_id']);
        $update_prices->MoveNext();
    }
}
コード例 #11
0
 function save_product($product)
 {
     global $db;
     global $sql_data_array;
     global $language_id;
     global $zco_notifier;
     global $product_save;
     global $products_id;
     global $messageStack;
     $products_id = $product['products_id'];
     $insert_products = $products_id == 0;
     // イメージ保存
     $products_image = new upload('products_image');
     $products_image->set_destination(DIR_FS_CATALOG_IMAGES . 'large/' . $_POST['img_dir']);
     if ($products_image->parse()) {
         $match = self::separate_filename($products_image->filename);
         $name = $match['name'];
         $ext = $match['ext'];
         if ($_POST['overwrite'] == 0 && file_exists(DIR_FS_CATALOG_IMAGES . $_POST['img_dir'] . $name . "." . $ext)) {
             $messageStack->add_session(TEXT_IMAGE_OVERWRITE_WARNING . $this->filename, 'caution');
             $products_image_name = isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '';
         } else {
             if ($products_image->save(1)) {
                 // 保存画像をリサイズ変換する
                 $products_image_name = $_POST['img_dir'] . self::image_resize(DIR_FS_CATALOG_IMAGES . 'large/' . $_POST['img_dir'], $products_image->filename, DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
             } else {
                 $products_image_name = isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '';
             }
         }
     } else {
         $products_image_name = isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '';
     }
     $match = self::separate_filename($products_image_name);
     $name = basename($match['name']);
     $ext = $match['ext'];
     // 追加画像
     // 追加画像は上記画像と拡張子を自動的に合わせる
     $find_addition_images = 0;
     for ($i = 1; $i <= MODULE_EASY_ADMIN_PRODUCTS_MAX_ADDITIONAL_IMAGES; $i++) {
         // 画像が追加、もしくは変更された
         if (isset($_FILES['products_additional_image_' . $i])) {
             $products_image = new upload('products_additional_image_' . $i);
             $products_image->set_destination(DIR_FS_CATALOG_IMAGES . 'large/' . $_POST['img_dir']);
             if ($products_image->parse()) {
                 $find_addition_images++;
                 $products_image->filename = $name . "_" . $find_addition_images . '.' . $ext;
                 $products_image->save(1);
                 self::image_resize(DIR_FS_CATALOG_IMAGES . 'large/' . $_POST['img_dir'], $products_image->filename, DIR_FS_CATALOG_IMAGES . $_POST['img_dir'], $products_image->filename);
             } else {
                 if (isset($_POST['products_additional_image_previous_' . $i])) {
                     $find_addition_images++;
                 }
             }
         } else {
             if (isset($_POST['products_additional_image_previous_' . $i])) {
                 $find_addition_images++;
             }
         }
     }
     // products
     // 特殊価格
     if ($product['specials_price_status'] == 0) {
         $product['products_priced_by_attribute'] = 0;
         $product['product_is_free'] = 0;
         $product['product_is_call'] = 0;
     } else {
         if ($product['specials_price_status'] == 1) {
             $product['products_priced_by_attribute'] = 0;
             $product['product_is_free'] = 0;
             $product['product_is_call'] = 0;
         } else {
             if ($product['specials_price_status'] == 2) {
                 $product['products_priced_by_attribute'] = 0;
                 $product['product_is_free'] = 1;
                 $product['product_is_call'] = 0;
             } else {
                 if ($product['specials_price_status'] == 3) {
                     $product['products_priced_by_attribute'] = 0;
                     $product['product_is_free'] = 0;
                     $product['product_is_call'] = 1;
                 }
             }
         }
     }
     $sql_data_array = array('products_type' => $product['products_type'], 'products_quantity' => $product['products_quantity'], 'products_model' => $product['products_model'], 'products_image' => $products_image_name, 'products_price' => $product['products_price'], 'products_virtual' => $product['products_virtual'], 'products_date_available' => $product['products_date_available'] == "" ? 'null' : $product['products_date_available'], 'products_weight' => $product['products_weight'], 'products_status' => $product['products_status'], 'products_tax_class_id' => $product['products_tax_class_id'], 'manufacturers_id' => $product['manufacturers_id'], 'products_quantity_order_min' => $product['products_quantity_order_min'], 'products_quantity_order_units' => $product['products_quantity_order_units'], 'products_priced_by_attribute' => $product['products_priced_by_attribute'], 'product_is_free' => $product['product_is_free'], 'product_is_call' => $product['product_is_call'], 'products_quantity_mixed' => $product['products_quantity_mixed'], 'product_is_always_free_shipping' => $product['product_is_always_free_shipping'], 'products_qty_box_status' => $product['products_qty_box_status'], 'products_quantity_order_max' => $product['products_quantity_order_max'], 'products_sort_order' => $product['products_sort_order'], 'products_discount_type' => $product['products_discount_type'], 'products_discount_type_from' => $product['products_discount_type_from'], 'products_price_sorter' => $product['products_price'], 'master_categories_id' => (int) $product['categories'], 'products_mixed_discount_quantity' => $product['products_mixed_discount_quantity'], 'metatags_title_status' => $product['metatags_title_status'], 'metatags_products_name_status' => $product['metatags_products_name_status'], 'metatags_model_status' => $product['metatags_model_status'], 'metatags_price_status' => $product['metatags_price_status'], 'metatags_title_tagline_status' => $product['metatags_title_tagline_status']);
     $product_save = $product;
     $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_BEFORE_SAVE_PRODUCTS');
     if ($insert_products) {
         $sql_data_array['products_date_added'] = 'now()';
         zen_db_perform(TABLE_PRODUCTS, $sql_data_array);
         $products_id = zen_db_insert_id();
     } else {
         $sql_data_array['products_last_modified'] = 'now()';
         zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id=" . (int) $products_id);
     }
     // products_to_categories
     // いったんすべてのカテゴリを削除後、追加する
     $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id=" . (int) $products_id);
     $array = explode(",", $product['categories_id']);
     foreach ($array as $v) {
         if ($v > 0) {
             $sql_data_array = array('products_id' => $products_id, 'categories_id' => $v);
             zen_db_perform(TABLE_PRODUCTS_TO_CATEGORIES, $sql_data_array);
         }
     }
     // products_description
     foreach ($product['products_description_products_name'] as $k => $v) {
         $sql_data_array = array('products_id' => $products_id, 'language_id' => $k, 'products_name' => $product['products_description_products_name'][$k], 'products_description' => $product['products_description_products_description'][$k], 'products_url' => $product['products_description_products_url'][$k]);
         $language_id = $k;
         $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_BEFORE_SAVE_PRODUCTS_DESCRIPTION');
         if ($insert_products) {
             zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
         } else {
             zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id=" . (int) $products_id . " and language_id=" . $k);
         }
     }
     // meta_tags_products_description
     if (is_array($product['meta_tags_products_description_metatags_title'])) {
         foreach ($product['meta_tags_products_description_metatags_title'] as $k => $v) {
             $sql_data_array = array('products_id' => $products_id, 'language_id' => $k, 'metatags_title' => $product['meta_tags_products_description_metatags_title'][$k], 'metatags_keywords' => $product['meta_tags_products_description_metatags_keywords'][$k], 'metatags_description' => $product['meta_tags_products_description_metatags_description'][$k]);
             $language_id = $k;
             $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_BEFORE_SAVE_META_TAGS_PRODUCTS_DESCRIPTION');
             $query = "select * from " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " where products_id=" . (int) $products_id . " and language_id=" . $k;
             $check = $db->Execute($query);
             if ($check->EOF) {
                 zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array);
             } else {
                 zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id=" . (int) $products_id . " and language_id=" . $k);
             }
         }
     }
     // featured
     if (isset($product['featured_status'])) {
         if ($product['featured_expires_date'] == "") {
             $product['featured_expires_date'] = '0001-01-01';
         }
         if ($product['featured_featured_date_available'] == "") {
             $product['featured_featured_date_available'] = '0001-01-01';
         }
         if ($product['featured_status'] == 1) {
             $sql_data_array = array('products_id' => $products_id, 'expires_date' => $product['featured_expires_date'], 'status' => $product['featured_status'], 'featured_date_available' => $product['featured_featured_date_available']);
             $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_BEFORE_SAVE_FEATURED');
             if ($product['featured_featured_id'] == 0) {
                 $sql_data_array['featured_date_added'] = 'now()';
                 zen_db_perform(TABLE_FEATURED, $sql_data_array);
                 $product['featured_featured_id'] = zen_db_insert_id();
             } else {
                 $sql_data_array['featured_last_modified'] = 'now()';
                 zen_db_perform(TABLE_FEATURED, $sql_data_array, "update", "featured_id=" . $product['featured_featured_id']);
             }
         } else {
             $db->Execute("delete from " . TABLE_FEATURED . " where products_id=" . (int) $products_id);
         }
     }
     // specials
     if (isset($product['specials_price_status'])) {
         if ($product['specials_expires_date'] == "") {
             $product['specials_expires_date'] = '0001-01-01';
         }
         if ($product['specials_specials_date_available'] == "") {
             $product['specials_specials_date_available'] = '0001-01-01';
         }
         if ($product['specials_price_status'] == 0 || $product['specials_price_status'] == 1) {
             $sql_data_array = array('products_id' => $products_id, 'specials_new_products_price' => $product['specials_specials_new_products_price'], 'expires_date' => $product['specials_expires_date'], 'status' => $product['specials_price_status'], 'specials_date_available' => $product['specials_specials_date_available']);
             $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_BEFORE_SAVE_SPECIALS');
             if ($product['specials_specials_id'] == 0) {
                 $sql_data_array['specials_date_added'] = 'now()';
                 zen_db_perform(TABLE_SPECIALS, $sql_data_array);
                 $product['specials_specials_id'] = zen_db_insert_id();
             } else {
                 $sql_data_array['specials_last_modified'] = 'now()';
                 zen_db_perform(TABLE_SPECIALS, $sql_data_array, "update", "specials_id=" . $product['specials_specials_id']);
             }
         } else {
             $db->Execute("delete from " . TABLE_SPECIALS . " where products_id=" . (int) $products_id);
         }
     }
     zen_update_products_price_sorter($products_id);
     $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_FINISH_SAVE');
     if ($insert_products) {
         $zco_notifier->notify('NOTIFY_EASY_ADMIN_PRODUCTS_FINISH_INSERT');
     }
     return $products_id;
 }