植松
miu_miu11****@yahoo*****
2006年 10月 29日 (日) 13:08:49 JST
みなさん、こんにちは。 植松です。 easypopulate.phpのソース全文だと非常に長文になり、 MLでは逆にみなさんのご迷惑にもなり、 Frank Black様にも、何度も手間をかけさせてしまい、 申し訳ないと思ったので、直メールで・・・ とお願いしてしまったのですが、 MLを閲覧している方々に結果がわからず、MLの趣旨に反していると Frank Black様よりご指摘いただき、考えが足りなかったと 反省しております。申し訳ございません。 にも関わらず、私の事情を察してソールファイルを送ってくださった Frank Black様、このMLを閲覧されている方々のためにも、 ソースのどの部分が異なり、どのような結果となったか、 ご報告させていただきます。 長文になりますが、宜しくお願いいたします。 **************** Frank Black様よりお送りいただいたソースファイルと自分のファイルを見比べ、 以下の部分を変更することにより、オプション付きでの商品一括登録が うまくいきました。Frank Black様、本当にありがとうございます。 ----------------------------- 918行目付近 ----------------------------- if ($localfile){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); の後に以下を挿入。 $attribute_options_values = tep_db_query($attribute_options_query); $attribute_options_count = 1; //while ($attribute_options = tep_db_fetch_array ($attribute_options_values)){ ----------------------------- 727行目付近 ----------------------------- // If you have other modules that need to be available, put them here の後に以下を挿入。 // VJ product attribs begin if (isset($filelayout['v_attribute_options_id_1'])){ $languages = tep_get_languages(); $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options) { $row['v_attribute_options_id_' . $attribute_options_count] = $attribute_options['products_options_id']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_options_languages_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_options_languages_values = tep_db_query ($attribute_options_languages_query); $attribute_options_languages = tep_db_fetch_array ($attribute_options_languages_values); $row['v_attribute_options_name_' . $attribute_options_count . '_' . $lid] = $attribute_options_languages ['products_options_name']; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query ($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array ($attribute_values_values)) { $row['v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values ['products_options_values_id']; $attribute_values_price_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$row['v_products_id'] . "' and options_id = '" . (int)$attribute_options ['products_options_id'] . "' and options_values_id = '" . (int)$attribute_values ['products_options_values_id'] . "'"; $attribute_values_price_values = tep_db_query ($attribute_values_price_query); $attribute_values_price = tep_db_fetch_array ($attribute_values_price_values); $row['v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values_price ['price_prefix'] . $attribute_values_price['options_values_price']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_values_languages_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_values_languages_values = tep_db_query($attribute_values_languages_query); $attribute_values_languages = tep_db_fetch_array($attribute_values_languages_values); $row['v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid] = $attribute_values_languages['products_options_values_name']; } $attribute_values_count++; } $attribute_options_count++; } } // VJ product attribs end ----------------------------- 1302行目付近 ----------------------------- // uncomment the customer_price and customer_group to support multi-price per product contrib 後に以下を挿入。、 // VJ product attribs begin $header_array = array( 'v_products_price' => $iii++, 'v_products_weight' => $iii++, 'v_date_avail' => $iii++, 'v_date_added' => $iii++, 'v_products_quantity' => $iii++, ); $languages = tep_get_languages(); global $attribute_options_array; $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options_values) { $key1 = 'v_attribute_options_id_' . $attribute_options_count; $header_array[$key1] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id; $header_array[$key2] = $iii++; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query ($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array ($attribute_values_values)) { $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key3] = $iii++; $key4 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key4] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key5 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id; $header_array[$key5] = $iii++; } $attribute_values_count++; } $attribute_options_count++; } $header_array['v_manufacturers_name'] = $iii++; $filelayout = array_merge($filelayout, $header_array); // VJ product attribs end ----------------------------- 2463行目付近 ----------------------------- if ($v_customer_price_4 != ''){ $result = tep_db_query(' INSERT INTO products_groups VALUES ( ' . $v_customer_group_id_4 . ', ' . $v_customer_price_4 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } } の下に以下を挿入。 // VJ product attribs begin if (isset($v_attribute_options_id_1)){ $attribute_rows = 1; // master row count $languages = tep_get_languages(); // product options count $attribute_options_count = 1; $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count; while (isset($$v_attribute_options_id_var) && !empty($$v_attribute_options_id_var)) { // remove product attribute options linked to this product before proceeding further // this is useful for removing attributes linked to a product $attributes_clean_query = "delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "'"; tep_db_query($attributes_clean_query); $attribute_options_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "'"; $attribute_options_values = tep_db_query ($attribute_options_query); // option table update begin if ($attribute_rows == 1) { // insert into options table if no option exists if (tep_db_num_rows($attribute_options_values) <= 0) { for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid; if (isset ($$v_attribute_options_name_var)) { $attribute_options_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int) $$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')"; $attribute_options_insert = tep_db_query($attribute_options_insert_query); } } } else { // update options table, if options already exists for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid; if (isset ($$v_attribute_options_name_var)) { $attribute_options_update_lang_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "' and language_id ='" . (int)$lid . "'"; $attribute_options_update_lang_values = tep_db_query($attribute_options_update_lang_query); // if option name doesn't exist for particular language, insert value if (tep_db_num_rows ($attribute_options_update_lang_values) <= 0) { $attribute_options_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int) $$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')"; $attribute_options_lang_insert = tep_db_query($attribute_options_lang_insert_query); } else { // if option name exists for particular language, update table $attribute_options_update_query = "update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . $$v_attribute_options_name_var . "' where products_options_id ='" . (int)$$v_attribute_options_id_var . "' and language_id = '" . (int)$lid . "'"; $attribute_options_update = tep_db_query($attribute_options_update_query); } } } } } // option table update end // product option values count $attribute_values_count = 1; $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; while (isset($$v_attribute_values_id_var) && !empty($$v_attribute_values_id_var)) { $attribute_values_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "'"; $attribute_values_values = tep_db_query ($attribute_values_query); // options_values table update begin if ($attribute_rows == 1) { // insert into options_values table if no option exists if (tep_db_num_rows($attribute_values_values) <= 0) { for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid; if (isset ($$v_attribute_values_name_var)) { $attribute_values_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int) $$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')"; $attribute_values_insert = tep_db_query($attribute_values_insert_query); } } // insert values to pov2po table $attribute_values_pov2po_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int) $$v_attribute_values_id_var . "')"; $attribute_values_pov2po = tep_db_query($attribute_values_pov2po_query); } else { // update options table, if options already exists for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid; if (isset ($$v_attribute_values_name_var)) { $attribute_values_update_lang_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int) $$v_attribute_values_id_var . "' and language_id ='" . (int)$lid . "'"; $attribute_values_update_lang_values = tep_db_query($attribute_values_update_lang_query); // if options_values name doesn't exist for particular language, insert value if (tep_db_num_rows ($attribute_values_update_lang_values) <= 0) { $attribute_values_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int) $$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')"; $attribute_values_lang_insert = tep_db_query($attribute_values_lang_insert_query); } else { // if options_values name exists for particular language, update table $attribute_values_update_query = "update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . $$v_attribute_values_name_var . "' where products_options_values_id ='" . (int)$$v_attribute_values_id_var . "' and language_id = '" . (int)$lid . "'"; $attribute_values_update = tep_db_query($attribute_values_update_query); } } } } } // options_values table update end // options_values price update begin $v_attribute_values_price_var = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; if (isset($$v_attribute_values_price_var) && ($$v_attribute_values_price_var != '')) { $attribute_prices_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id ='" . (int)$$v_attribute_options_id_var . "' and options_values_id = '" . (int)$$v_attribute_values_id_var . "'"; $attribute_prices_values = tep_db_query ($attribute_prices_query); $attribute_values_price_prefix = ($$v_attribute_values_price_var < 0) ? '-' : '+'; // options_values_prices table update begin // insert into options_values_prices table if no price exists if (tep_db_num_rows($attribute_prices_values) <= 0) { $attribute_prices_insert_query = "insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$v_products_id . "', '" . (int) $$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "', '" . (float) $$v_attribute_values_price_var . "', '" . $attribute_values_price_prefix . "')"; $attribute_prices_insert = tep_db_query($attribute_prices_insert_query); } else { // update options table, if options already exists $attribute_prices_update_query = "update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $$v_attribute_values_price_var . "', price_prefix = '" . $attribute_values_price_prefix . "' where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int) $$v_attribute_options_id_var . "' and options_values_id ='" . (int)$$v_attribute_values_id_var . "'"; $attribute_prices_update = tep_db_query($attribute_prices_update_query); } } // options_values price update end $attribute_values_count++; $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; } $attribute_options_count++; $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count; } $attribute_rows++; } // VJ product attribs end ------------------------------------------ 603行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here から // end support for Header Controller 2.0 をコメントアウト。 ------------------------------------------ 1285行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here 内の 'v_products_head_title_tag_'.$l_id => $iii++, 'v_products_head_desc_tag_'.$l_id => $iii++, 'v_products_head_keywords_tag_'.$l_id => $iii++, をコメントアウト。 ------------------------------------------ 1810行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here から // end support for Header Controller 2.0 をコメントアウト。 ------------------------------------------ 1943行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here から // end support for Header Controller 2.0 をコメントアウト。 ------------------------------------------ 2367行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here から // end support for Header Controller 2.0 をコメントアウト。 ------------------------------------------ 2433行目付近 ------------------------------------------ // support for Linda's Header Controller 2.0 here から // end support for Header Controller 2.0 をコメントアウト。 以上となります。 最後に、 Frank Black様には、お忙しいところ何度もご助言いただき、 また、本意ではないのに、ソースファイルをお送りいただいたりと、 ご迷惑をおかけして、本当に申し訳ございませんでした。 Frank Black様のおかげで、なんとか無事、オプション付きでの商品一括登録を 実現することができました。 心から感謝申しあげます。 本当にどうもありがとうございました。