Magento 2 CMS is the preferred platform to build E-commerce stores owing to its features that address modern business requirements.
One such feature is customer groups in Magento 2 that help in targeted customer management, customer-wise marketing efforts, and developing features based on types of customers.
If you are a store owner with a wide variety of products and a large customer base with various customer types, managing customer groups is an essential task.
Customer groups let you categorize the store’s customer base into different groups. Once you have grouped customers, you can create rules, tax classes, and group-specific discounts that pertain to individual customer groups.
The Magento 2 offers the following customer group types:
- Not Logged in
Besides these, one can create a customer group programmatically in Magento 2 based on custom business requirements.
While working with the extensions based on customer groups, one often needs to get all customer groups in Magento 2.
For instance, the admin wants to offer different pricing strategies for wholesalers only and cash on delivery option should only be enabled for VIP customer groups.
Or “instant delivery” is to be offered only to higher customer groups. Or, restrict a payment method for not logged in customer group.
In all such scenarios, one needs to get all customer groups in Magento 2 and use the below solution for the same:
Solution to get all customer groups in Magento 2
Create a Helper file at Vendor/Extension/Helper.
use Magento\Customer\Model\ResourceModel\Group\Collection as CustomerGroup;
class Data extends AbstractHelper
public function __construct(
$this->customerGroup = $customerGroup;
public function getCustomerGroups()
$customerGroups = $this->customerGroup->toOptionArray();
Use the getCustomerGroups() of helper file, where you want to get all customer groups.
If you have any doubt regarding this post, do mention in the Comments section below.
I would be glad to be of help.
Don’t forget to share this solution with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.