[-] BO: Filter customers listing by shop context on AdminGroups
This commit is contained in:
@@ -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 : ''));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user