Don’t forget to share this solution with Magento Community via social media.
Thank you for subscribing.
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.
Create a Helper file at Vendor/Extension/Helper.
If you have any doubt regarding this post, do mention in the Comments section below.
- Not Logged in
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.
In all such scenarios, one needs to get all customer groups in Magento 2 and use the below solution for the same:
While working with the extensions based on customer groups, one often needs to get all customer groups in Magento 2.
Or “instant delivery” is to be offered only to higher customer groups. Or, restrict a payment method for not logged in customer group.
Magento 2 CMS is the preferred platform to build E-commerce stores owing to its features that address modern business requirements.
Solution to get all customer groups in Magento 2
use MagentoCustomerModelResourceModelGroupCollection as CustomerGroup;
class Data extends AbstractHelper
public function __construct(
$this->customerGroup = $customerGroup;
public function getCustomerGroups()
$customerGroups = $this->customerGroup->toOptionArray();
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.
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.
Something went wrong.
The Magento 2 offers the following customer group types:
Besides these, one can create a customer group programmatically in Magento 2 based on custom business requirements.
Get Weekly Updates
Use the getCustomerGroups() of helper file, where you want to get all customer groups.
Never miss Magento tips, tricks, tutorials, and news.
I would be glad to be of help.