C'est une adaptation perso que j'ai faite.
Je vais essayer de la détailler ici
1/ ajouter un champ dans la table products :
SQL
ALTER TABLE `products` ADD `customers_id` INT( 11 ) NOT NULL DEFAULT '0' AFTER `manufacturers_id` ;
Après il faut modifier le fichier categories.php de l'admin :
rechercher la section qui commence par :
CODE
$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
et modifier la fin en ajoutant le nouveau champ, ça doit ressembler à ça pour finir :
CODE
'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']),
'customers_id' => tep_db_prepare_input($HTTP_POST_VARS['customers_id']));
Plus loin dans la section qui commence par
CODE
} elseif ($action == 'new_product') {
$parameters = array('products_name' => '',
modifier la fin pour insérer le nouveau champ :
CODE
'manufacturers_id' => '',
'customers_id' => '');
Juste après on a une requête select qui est précédée par
CODE
$pInfo = new objectInfo($parameters);
if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
dans la requête qui commence par
$product_query = tep_db_query("select pd.products_name, pd.products_description, .... juste après
p.manufacturers_id, on ajoute
p.customers_id,plus bas juste après la section
CODE
$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']);
}
on ajoute ceci :
CODE
//########Ajout sélection clients
$customers_array = array(array('id' => '', 'text' => TEXT_NONE));
$customers_query = tep_db_query("select customers_id, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
while ($customers = tep_db_fetch_array($customers_query)) {
$customers_array[] = array('id' => $customers['customers_id'],
'text' => strtoupper($customers['customers_lastname']).', '.$customers['customers_firstname']);
}
//######## FIN Ajout sélection clients
plus bas, après la section (ou avant comme tu veux)
CODE
<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>
on ajoute
CODE
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_CUSTOMER; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('customers_id', $customers_array, $pInfo->customers_id); ?></td>
</tr>
dans la suite du code on ajoute dans chaque requête où il y a
p.products_status, on ajoute
p.customers_id, ce qui doit donner :
p.products_status, p.customers_id,Bon pour la partie admin ça devrait être terminé.
Pour la partie catalogue, il faut filtrer les produits de la même manière que si le produit était inactif :
on recherche dans tous les fichier (racine, rep includes/boxes et includes/module) les requêtes qui contiennent :
where p.products_status = '1' et on remplace par
where p.products_status = '1' and ( p.customers_id = '" . (int)$customer_id . "' or p.customers_id = '0')voilà, ça devrait le faire
Pour faire ces modifs, il faut un bon éditeur de texte qui permet des recherches comme PsPad (lien dans ma signature)