Step 1:
If you have standard distribution you can copy included admin/categories.php file over yours
(Do not forget to Backup your copy)
NOTE: If you use included file skip this step and go to Step 2
In admin/categories.php file
After
...
case 'insert_product':
case 'update_product':
ADD
// copy image only if modified
$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($products_image->parse() && $products_image->save()) {
$products_image_name = $products_image->filename;
} else {
$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
}
// copy image only if modified
REPLACE
if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
}
WITH
if (isset($products_image_name) && tep_not_null($products_image_name) && ($products_image_name != 'none')) {
$sql_data_array['products_image'] = tep_db_prepare_input($products_image_name);
}
After
...
if ($action == 'insert_product') {
$insert_sql_data = array('products_date_added' => 'now()');
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
$products_id = tep_db_insert_id();
DELETE line:
tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . $products_id . "', '" . $current_category_id . "')");
In this cestion
...
} elseif ($action == 'update_product') {
$update_sql_data = array('products_last_modified' => 'now()');
$sql_data_array = array_merge($sql_data_array, $update_sql_data);
tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
!!! INSERT HERE !!
}
ADD line
#delete categories saved in the tables
tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '". $products_id . "'");
After this section ADD
# create loop here to insert rows for multiple categories
$selected_catids = $HTTP_POST_VARS['categories_ids'];
if (!$selected_catids) $selected_catids[0] = 0;
foreach ($selected_catids as $current_category_id)
{
tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . $products_id . "', '" . $current_category_id . "')");
}
After
...
$manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
'text' => $manufacturers['manufacturers_name']);
}
ADD (fixed by Snowbird 11/07/2003)
# get selected categories
$categories_query_selected = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $HTTP_GET_VARS['pID'] . "'");
$categories_array_selected = array(array('id' => ''));
while ($categories = tep_db_fetch_array($categories_query_selected)) {
$categories_array_selected[] = array('id' => $categories['categories_id']);
}
$categories_array = array(array('id' => '', 'text' => TEXT_NONE));
#Categories list displays only for one languge (Default is English)
$language_id = 1;
$categories_array = tep_get_category_tree(); // added by R Calder
$form_action = ($HTTP_GET_VARS['pID']) ? 'update_product' : 'insert_product';
REPLACE
<?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?>
WITH
<?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID'] . '&action='. $form_action, 'post', 'enctype="multipart/form-data"'); ?>
After
...
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>
</tr>
ADD (to display multiple select menu...)
<tr>
<td class="main"><?php echo TEXT_CATEGORIES; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_mselect_menu('categories_ids[]', $categories_array, $categories_array_selected, 'size=10'); ?></td>
</tr>
OR (to display checkboxes...)
<tr>
<td class="main"><?php echo TEXT_CATEGORIES; ?></td>
<td class="main">Select Categories È<br />
<div id="categoryDiv"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_chbox_cat_menu('categories_ids[]', $categories_array, $categories_array_selected, 'size=10'); ?></div></td>
</tr>
REPLACE
... tep_image_submit('button_preview.gif', IMAGE_PREVIEW) ...
WHITH
tep_image_submit('button_save.gif', IMAGE_SAVE)
Partager