Voici les modifications à effectuer:
Dans product-sort.php
Ajouter après la ligne 7 ($orderWay = ...):
$orderNewProductsBy = Tools::strtolower(Tools::getValue('ordernewproductsby', $orderByValues[intval(Configuration::get('PS_NEW_PRODUCTS_ORDER_BY'))]));
$orderNewProductsWay = Tools::strtoupper(Tools::getValue('ordernewproductsway', $orderWayValues[intval(Configuration::get('PS_NEW_PRODUCTS_ORDER_WAY'))]));
if (!in_array($orderNewProductsBy, $orderByValues))
$orderNewProductsBy = $orderByValues[0];
if (!in_array($orderNewProductsWay, $orderWayValues))
$orderNewProductsWay = $orderWayValues[0];
Ajouter après la ligne 21 ( 'orderway' => $orderWay,):
'ordernewproductsby' => $orderNewProductsBy,
'ordernewproductsway' => $orderNewProductsWay,
Dans le fichier new-products.php
remplacer la ligne 11 par:
'products' => Product::getNewProducts(intval($cookie->id_lang), intval($p) - 1, intval($n), false, $orderNewProductsBy, $orderNewProductsWay),
Dans votre admin/tabs/AdminPPreferences.php
Insérer le code suivant
entre la ligne 44 ('PS_PRODUCTS_ORDER_WAY' => ...) :
et 45 ('PS_IMAGE_GENERATION_METHOD' => ...) :
'PS_NEW_PRODUCTS_ORDER_BY' => array('title' => $this->l('Default new products order by:'), 'desc' => $this->l('Default order by for new products list'), 'type' => 'select', 'list' =>
array(
array('id' => '0', 'name' => $this->l('Product name')),
array('id' => '1', 'name' => $this->l('Product price')),
array('id' => '2', 'name' => $this->l('Product added date')),
array('id' => '4', 'name' => $this->l('Position inside category')),
array('id' => '5', 'name' => $this->l('Manufacturer')),
array('id' => '3', 'name' => $this->l('Product modified date'))
), 'identifier' => 'id'),
'PS_NEW_PRODUCTS_ORDER_WAY' => array('title' => $this->l('Default new products order way:'), 'desc' => $this->l('Default order way for new products list'), 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Ascending')), array('id' => '1', 'name' => $this->l('Decreasing'))), 'identifier' => 'id'),
Dans classes/Product.php (function getNewProducts)
//Correction bug pagination
remplacer les lignes 903 (if ($count)) à 911 par:
if ($count)
{
$result = Db::getInstance()->getRow('
SELECT COUNT(`id_product`) AS nb
FROM `'._DB_PREFIX_.'product`
WHERE `active` = 1
AND DATEDIFF(`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0');
return intval($result['nb']);
}
Dans votre theme, dans le fichier product-sort.tpl
Insérer après la ligne 21 (
Faire une copie du fichier product-sort.tpl et renommer cette copie en new-product-sort.tpl
Ensuite remplacer
tous les $orderby par $ordernewproductsby
tous les $orderway par $ordernewproductsway
et tous les addSortDetails en addNewProductsSortDetails
Dans votre fichier theme/new-products.tpl
Remplacer la ligne 7 ( {include file=$tpl_dir./product-sort.tpl}) par:
{include file=$tpl_dir./new-product-sort.tpl}
Dans le fichier classes/Link.php
Ajouter après la fonction addSortDetails (ligne 165 à 168)
public function addNewProductsSortDetails($url, $ordernewproductsby, $ordernewproductsway)
{
return $url.(!strstr($url, '?') ? '?' : '&').'ordernewproductsby='.urlencode($ordernewproductsby).'&ordernewproductsway;='.urlencode($ordernewproductsway);
}
Ensuite vous pourrez choisir le tri à attribuer par défaut au site et aux nouveaux produits dans la partie administration/Préférences/Produits.
Le texte sera en anglais, il faut le traduire en utilisant l'onglet outils traduction.




Back to top












