Today we will learn how to list all customer group in magento 2. Getting the complete list of customers/users means displaying a list of all the customer groups including not logged in group as well.
So,you can get the complete list of customer groups,using following code:
class Product extends \Magento\Framework\View\Element\Template
public function __construct(
$this->groupCollection = $groupCollection;
public function getCustomerGroup()
$groupOptions = $objectManager->get('\Magento\Customer\Model\ResourceModel\Group\Collection')->toOptionArray();
'name' => 'customer_group',
'label' => __('Customer Group'),
'title' => __('Customer Group'),
'values' => $groupOptions,
'disabled' => $isElementDisabled
One can also use the following class:
This class provides the
method which can be used to get an array of customer groups.
That’s it for this tutorial. I hope it will help you in a certain and easy way.
Give A Rating
Average Rating / 5. Vote Count