Bonjour
cette modification a été testé sur PS 1.4 et elle fonctionne très bien
Vous pouvez suivre ces étapes:
1-dabord chercher ce code vers la ligne 130 dans admin/Tabs/adminsearch.php et ajouter cette ligne
'ean13' => array('title' => $this->l('EAN13')),
on obtient
if (!$searchType OR $searchType == 1)
{
$this->fieldsDisplay['catalog'] = (array(
'ID' => array('title' => $this->l('ID')),
'manufacturer' => array('title' => $this->l('Manufacturer')),
'reference' => array('title' => $this->l('Reference')),
'ean13' => array('title' => $this->l('EAN13')),
'name' => array('title' => $this->l('Name')),
'price' => array('title' => $this->l('Price')),
'stock' => array('title' => $this->l('Stock')),
'status' => array('title' => $this->l('Status')),
'action' => array('title' => $this->l('Actions'))
));
/* Handle product ID */
if ($searchType == 1 AND (int)$query AND Validate::isUnsignedInt((int)$query))
if ($product = new Product((int)$query) AND Validate::isLoadedObject($product))
Tools::redirectAdmin('index.php?tab=AdminCatalog&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));
/* Normal catalog search */
$this->searchCatalog($query);
}
2-puis cherchez ce code vers la ligne 241 :
foreach ($this->_list['products'] AS $k => $product)
{
echo '
<tr>
<td>'.$product['id_product'].'</td>
<td align="center">'.($product['manufacturer_name'] != NULL ? stripslashes($product['manufacturer_name']) : '--').'</td>
<td>'.$product['reference'].'</td>
<td><a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">'.stripslashes($product['nameh']).'</a></td>
<td>'.Tools::displayPrice($product['price'], $currency).'</td>
<td align="center">'.$product['quantity'].'</td>
<td align="center"><a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&status&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">
<img src="../img/admin/'.($product['active'] ? 'enabled.gif' : 'forbbiden.gif').'" alt="" /></a></td>
<td>
<a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this product').'" /></a>
<a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"
onclick="return confirm(\''.$this->l('Do you want to delete this product?', __CLASS__, true, false).' ('.addslashes($product['name']).')\');">
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this product').'" /></a>
</td>
</tr>';
}
3-ajouter la ligne suivante :
<td>'.$product['ean13'].'</td>
juste après
<td>'.$product['reference'].'</td>
4-On va maintenant modifier la fonction de recherche dans la classe Product.php
en ajoutant la récupération de EAN13 et en ajoutant
OR p.`ean13` LIKE \'%'.pSQL($query).'%\'
voila le syntaxe de la nouvelle fonction
public static function searchByName($id_lang, $query)
{
$result = Db::getInstance()->ExecuteS('
SELECT p.`id_product`, pl.`name`, p.`ean13`, p.`active`, p.`reference`, m.`name` AS manufacturer_name
FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product`
WHERE pl.`name` LIKE \'%'.pSQL($query).'%\' OR p.`reference` LIKE \'%'.pSQL($query).'%\' OR p.`ean13` LIKE \'%'.pSQL($query).'%\' OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\' OR pa.`reference` LIKE \'%'.pSQL($query).'%\'
GROUP BY `id_product`
ORDER BY pl.`name` ASC');
if (!$result)
return false;
$resultsArray = array();
foreach ($result AS $row)
{
$row['price'] = Product::getPriceStatic($row['id_product'], true, NULL, 2);
$row['quantity'] = Product::getQuantity($row['id_product']);
$resultsArray[] = $row;
}
return $resultsArray;
}