[-] BO: Filter customers listing by shop context on AdminGroups

This commit is contained in:
Rémi Gaillard
2013-02-25 20:08:33 +01:00
parent 74a766d145
commit 0f5f792bd8
2 changed files with 11 additions and 9 deletions

View File

@@ -84,7 +84,7 @@ class GroupCore extends ObjectModel
ORDER BY g.`id_group` ASC');
}
public function getCustomers($count = false, $start = 0, $limit = 0)
public function getCustomers($count = false, $start = 0, $limit = 0, $shop_filtering = false)
{
if ($count)
return Db::getInstance()->getValue('
@@ -92,6 +92,7 @@ class GroupCore extends ObjectModel
FROM `'._DB_PREFIX_.'customer_group` cg
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
'.($shop_filtering ? Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) : '').'
AND c.`deleted` != 1');
return Db::getInstance()->executeS('
SELECT cg.`id_customer`, c.*
@@ -99,6 +100,7 @@ class GroupCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
AND c.`deleted` != 1
'.($shop_filtering ? Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) : '').'
ORDER BY cg.`id_customer` ASC
'.($limit > 0 ? 'LIMIT '.(int)$start.', '.(int)$limit : ''));
}

View File

@@ -36,13 +36,6 @@ class AdminGroupsControllerCore extends AdminController
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->_select = '
(SELECT COUNT(jcg.`id_customer`)
FROM `'._DB_PREFIX_.'customer_group` jcg
LEFT JOIN `'._DB_PREFIX_.'customer` jc ON (jc.`id_customer` = jcg.`id_customer`)
WHERE jc.`deleted` != 1
AND jcg.`id_group` = a.`id_group`) AS nb';
$groups_to_keep = array(
Configuration::get('PS_UNIDENTIFIED_GROUP'),
Configuration::get('PS_GUEST_GROUP'),
@@ -90,6 +83,13 @@ class AdminGroupsControllerCore extends AdminController
$this->addRowActionSkipList('delete', $groups_to_keep);
parent::__construct();
$this->_select .= '(SELECT COUNT(jcg.`id_customer`)
FROM `'._DB_PREFIX_.'customer_group` jcg
LEFT JOIN `'._DB_PREFIX_.'customer` jc ON (jc.`id_customer` = jcg.`id_customer`)
WHERE jc.`deleted` != 1
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND jcg.`id_group` = a.`id_group`) AS nb';
}
public function setMedia()
@@ -158,7 +158,7 @@ class AdminGroupsControllerCore extends AdminController
'active' => array('title' => $this->l('Enabled'),'align' => 'center','width' => 20, 'active' => 'status','type' => 'bool')
));
$customer_list = $group->getCustomers(false);
$customer_list = $group->getCustomers(false, 0, 0, true);
$helper = new HelperList();
$helper->currentIndex = Context::getContext()->link->getAdminLink('AdminCustomers', false);