Salut,

j'ai un petit problème lié à lié à la contribution multiple category

ça ne me renome plus images au nom du produit.

exp: nom-du-nouveau-produit.jpg s'il me charge l'image il me la charge au nom réel du produit image
exp: 12434dgs.jpg

codes dans mon prochain message..

Merci d'avance..

------------------------

Salut,

alors voilà pour l'installation :
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') . '&nbsp;' . 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') . '&nbsp;' . 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)
là ou j'ai des doutes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
...
case 'insert_product':
      case 'update_product':
// copy image only if modified multicat
        $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 multicat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
// multicat
          }else 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);
          }
          // code initial avant multicat
          /*}else 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']);
          }*/
dans mon code initial j'ai ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
case 'new_product_preview':
          //BOF SEO images
          global $languages_id;
          $fabricante = tep_get_manufacturer_name($HTTP_POST_VARS['manufacturers_id']);
          $nombreProducto = $HTTP_POST_VARS['products_name'][$languages_id];
          //EOF SEO images
// copy image only if modified
        //BOF SEO images
       if (($HTTP_POST_VARS['unlink_image'] == 'yes') or ($HTTP_POST_VARS['delete_image'] == 'yes')) {
         $products_image = '';
         $products_image_name = '';
        } else {
         $products_image = new upload('products_image');
         $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
         if ($products_image->parse($fabricante, $nombreProducto) && $products_image->save()) {
           $products_image_name = $products_image->filename;
           // watermark    
          AddWatermark($products_image_name);
          //watermark end
         } else {
           $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
         }
du coup je me demande s'il n'y a pas une valeur qui ce perd quelque part.

sur demande je me les deux codes en entier avant et après multiple category.

ce que je ne saisi pas trop c'est pourquoi l'image du produit est liée à Multiple Catégory ?

c'est pas juste une histoire de catégories qu'on lie entre elles ?

et du coup ne pas toucher aux images initiales !! non ?

si vous avez une solution ou idée..

merci d'avance..