[-] BO : fixed issue with reduction in the category for groups #PSCFV-9101

This commit is contained in:
Damien Metzger committed 2013-05-15 15:23:13 +02:00
1 parent 2e00a1662e
commit e1afce7f22
1 file changed
+13 -17
+13 -17
View File
@@ -312,36 +312,32 @@ class AdminGroupsControllerCore extends AdminController
return parent::renderForm(); return parent::renderForm();
} }
protected function formatCategoryDiscountList($id) protected function formatCategoryDiscountList($id_group)
{ {
$category = GroupReduction::getGroupReductions((int)$id, $this->context->language->id); $group_reductions = GroupReduction::getGroupReductions((int)$id_group, $this->context->language->id);
$category_reductions = array(); $category_reductions = array();
$category_reduction = Tools::getValue('category_reduction'); $category_reduction = Tools::getValue('category_reduction');
foreach ($category as $category) foreach ($group_reductions as $category)
{ {
if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction)) if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction))
$category['reduction'] = $category_reduction[$category['id_category']]; $category['reduction'] = $category_reduction[$category['id_category']];
$tmp = array(); $category_reductions[(int)$category['id_category']] = array(
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']); 'path' => getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']),
$tmp['reduction'] = (float)$category['reduction'] * 100; 'reduction' => (float)$category['reduction'] * 100,
$tmp['id_category'] = (int)$category['id_category']; 'id_category' => (int)$category['id_category']
$category_reductions[(int)$category['id_category']] = $tmp; );
} }
if (is_array($category_reduction)) if (is_array($category_reduction))
foreach ($category_reduction as $key => $val) foreach ($category_reduction as $key => $val)
{
if (!array_key_exists($key, $category_reductions)) if (!array_key_exists($key, $category_reductions))
{ $category_reductions[(int)$key] = array(
$tmp = array(); 'path' => getPath(self::$currentIndex.'?tab=AdminCategories', $key),
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', $key); 'reduction' => (float)$val * 100,
$tmp['reduction'] = (float)$val * 100; 'id_category' => (int)$key
$tmp['id_category'] = (int)$key; );
$category_reductions[(int)$category['id_category']] = $tmp;
}
}
return $category_reductions; return $category_reductions;
} }