[*] BO : Carriers can now be sorted ascending or descending

This commit is contained in:
vChabot
2011-11-04 10:23:41 +00:00
parent 6093a3827b
commit 222c573ff0
3 changed files with 22 additions and 2 deletions
+7 -1
View File
@@ -44,6 +44,9 @@ class CarrierCore extends ObjectModel
const SORT_BY_PRICE = 0;
const SORT_BY_POSITION = 1;
const SORT_BY_ASC = 0;
const SORT_BY_DESC = 1;
/** @var int Tax id (none = 0) */
public $id_tax_rules_group;
@@ -554,7 +557,10 @@ class CarrierCore extends ObjectModel
{
foreach ($results_array as $r)
$prices[] = $r['price'];
array_multisort($prices, SORT_NUMERIC, $results_array);
if (Configuration::get('PS_CARRIER_DEFAULT_ORDER') == Carrier::SORT_BY_ASC)
array_multisort($prices, SORT_ASC, SORT_NUMERIC, $results_array);
else
array_multisort($prices, SORT_DESC, SORT_NUMERIC, $results_array);
}
return $results_array;
@@ -102,6 +102,11 @@ class AdminCarriersControllerCore extends AdminController
array('value' => Carrier::SORT_BY_POSITION, 'name' => $this->l('Position'))
);
$carrier_default_order = array(
array('value' => Carrier::SORT_BY_ASC, 'name' => $this->l('Ascending')),
array('value' => Carrier::SORT_BY_DESC, 'name' => $this->l('Descending'))
);
$this->options = array(
'general' => array(
'title' => $this->l('Carrier options'),
@@ -122,6 +127,14 @@ class AdminCarriersControllerCore extends AdminController
'identifier' => 'value',
'list' => $carrier_default_sort
),
'PS_CARRIER_DEFAULT_ORDER' => array(
'title' => $this->l('Carrier default order:'),
'desc' => $this->l('This default order will be available only on front-office'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'value',
'list' => $carrier_default_order
),
),
'submit' => array()
)
+2 -1
View File
@@ -331,7 +331,8 @@ INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_a
(155, 'PS_ADVANCED_STOCK_MANAGEMENT', '1', NOW(), NOW()),
(156, 'PS_ADMINREFRESH_NOTIFICATION', '1', NOW(), NOW()),
(157, 'PS_STOCK_MVT_TRANSFER_TO', '6', NOW(), NOW()),
(158, 'PS_STOCK_MVT_TRANSFER_FROM', '7', NOW(), NOW());
(158, 'PS_STOCK_MVT_TRANSFER_FROM', '7', NOW(), NOW()),
(159, 'PS_CARRIER_DEFAULT_ORDER', '0', NOW(), NOW());
INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES
(36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),