// Fixed #PSTEST-621

This commit is contained in:
bMancone
2012-02-01 14:07:44 +00:00
parent 0b9c73e127
commit 6bc8588b7a
@@ -48,13 +48,18 @@ class AdminAttributesGroupsControllerCore extends AdminController
'filter_key' => 'b!name', 'filter_key' => 'b!name',
'align' => 'left' 'align' => 'left'
), ),
'count_values' => array(
'title' => $this->l('Values'),
'width' => 25,
'align' => 'center'
),
'position' => array( 'position' => array(
'title' => $this->l('Position'), 'title' => $this->l('Position'),
'width' => 40, 'width' => 40,
'filter_key' => 'cp!position', 'filter_key' => 'cp!position',
'position' => 'position', 'position' => 'position',
'align' => 'center' 'align' => 'center'
) ),
); );
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
@@ -149,8 +154,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
$helper->bulk_actions = $this->bulk_actions; $helper->bulk_actions = $this->bulk_actions;
$content = $helper->generateList($this->_list, $this->fieldsDisplay); $content = $helper->generateList($this->_list, $this->fieldsDisplay);
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)); die (Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)));
exit;
} }
} }
@@ -372,7 +376,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
if ($this->display == 'add') if ($this->display == 'add')
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token; $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token;
else else
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&id_attribute_group='.(int)Tools::getValue('id_attribute_group').'&conf=3&update'.$this->table.'&token='.$token; $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'&conf=3&update'.$this->table.'&token='.$token;
} }
} }
@@ -579,7 +583,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
WHERE `id_attribute_group` = '.(int)Tools::getValue('id_attribute_group').' WHERE `id_attribute_group` = '.(int)Tools::getValue('id_attribute_group').'
ORDER BY position DESC'; ORDER BY position DESC';
// set the position of the new group attribute in $_POST for postProcess() method // set the position of the new group attribute in $_POST for postProcess() method
$_POST['position'] = DB::getInstance()->getValue($sql); $_POST['position'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
} }
$_POST['id_parent'] = 0; $_POST['id_parent'] = 0;
$this->processSave($this->token); $this->processSave($this->token);
@@ -619,7 +623,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
FROM `'._DB_PREFIX_.'attribute_group` FROM `'._DB_PREFIX_.'attribute_group`
ORDER BY position DESC'; ORDER BY position DESC';
// set the position of the new group attribute in $_POST for postProcess() method // set the position of the new group attribute in $_POST for postProcess() method
$_POST['position'] = DB::getInstance()->getValue($sql); $_POST['position'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
} }
// clean \n\r characters // clean \n\r characters
foreach ($_POST as $key => $value) foreach ($_POST as $key => $value)
@@ -631,4 +635,31 @@ class AdminAttributesGroupsControllerCore extends AdminController
parent::postProcess(); parent::postProcess();
} }
} }
/**
* AdminController::getList() override
* @see AdminController::getList()
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
$nb_items = count($this->_list);
for ($i = 0; $i < $nb_items; ++$i)
{
$item = &$this->_list[$i];
$query = new DbQuery();
$query->select('COUNT(id_attribute) as count_values');
$query->from('attribute', 'a');
$query->where('a.id_attribute_group ='.(int)$item['id_attribute_group']);
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
$item['count_values'] = (int)$res;
unset($res);
}
}
} }