Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer
Model
Customer
Source
Group.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Customer\Model\Customer\Source
;
7
8
use
Magento\Customer\Api\Data\GroupSearchResultsInterface
;
9
use
Magento\Framework\Module\Manager
as ModuleManager;
10
use
Magento\Customer\Api\Data\GroupInterface
;
11
use
Magento\Customer\Api\GroupRepositoryInterface
;
12
use
Magento\Framework\Api\SearchCriteriaBuilder
;
13
14
class
Group
implements
GroupSourceInterface
15
{
19
protected
$moduleManager
;
20
24
protected
$groupRepository
;
25
29
protected
$searchCriteriaBuilder
;
30
36
public
function
__construct
(
37
ModuleManager
$moduleManager
,
38
GroupRepositoryInterface
$groupRepository
,
39
SearchCriteriaBuilder
$searchCriteriaBuilder
40
) {
41
$this->moduleManager =
$moduleManager
;
42
$this->groupRepository =
$groupRepository
;
43
$this->searchCriteriaBuilder =
$searchCriteriaBuilder
;
44
}
45
51
public
function
toOptionArray
()
52
{
53
if
(!$this->moduleManager->isEnabled(
'Magento_Customer'
)) {
54
return
[];
55
}
56
$customerGroups = [];
57
$customerGroups[] = [
58
'label'
=>
__
(
'ALL GROUPS'
),
59
'value'
=> (string)
GroupInterface::CUST_GROUP_ALL
,
60
];
61
63
$groups = $this->groupRepository->getList($this->searchCriteriaBuilder->create());
64
foreach
($groups->getItems() as
$group
) {
65
$customerGroups[] = [
66
'label'
=>
$group
->getCode(),
67
'value'
=>
$group
->getId(),
68
];
69
}
70
71
return
$customerGroups;
72
}
73
}
Magento\Customer\Model\Customer\Source\Group\$searchCriteriaBuilder
$searchCriteriaBuilder
Definition:
Group.php:29
Magento\Customer\Model\Customer\Source\Group\$moduleManager
$moduleManager
Definition:
Group.php:19
Magento\Framework\Api\SearchCriteriaBuilder
Definition:
SearchCriteriaBuilder.php:14
$group
$group
Definition:
sections.phtml:16
__
__()
Definition:
__.php:13
Magento\Customer\Model\Customer\Source
Definition:
Group.php:6
Magento\Customer\Model\Customer\Source\Group\__construct
__construct(ModuleManager $moduleManager, GroupRepositoryInterface $groupRepository, SearchCriteriaBuilder $searchCriteriaBuilder)
Definition:
Group.php:36
Magento\Customer\Api\Data\GroupSearchResultsInterface
Definition:
GroupSearchResultsInterface.php:14
Magento\Customer\Api\Data\GroupInterface\CUST_GROUP_ALL
const CUST_GROUP_ALL
Definition:
GroupInterface.php:27
Magento\Framework\Module\Manager
Definition:
Manager.php:20
Magento\Customer\Model\Customer\Source\Group
Definition:
Group.php:14
Magento\Framework\Data\OptionSourceInterface\toOptionArray
toOptionArray()
Magento\Customer\Model\Customer\Source\GroupSourceInterface
Definition:
GroupSourceInterface.php:14
Magento\Customer\Api\GroupRepositoryInterface
Definition:
GroupRepositoryInterface.php:13
Magento\Customer\Model\Customer\Source\Group\$groupRepository
$groupRepository
Definition:
Group.php:24
Magento\Customer\Api\Data\GroupInterface
Definition:
GroupInterface.php:17