cancel
Showing results for 
Search instead for 
Did you mean: 

Add a customer to a group

SOLVED

Add a customer to a group

How do I add a customer to a group programatically in magento2

 

Tags (2)
2 REPLIES

Re: Add a customer to a group

Hi @arunsomanhere

 

did you try to use setGroupId() method on the customer model object?

 

/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
$customer->setGroupId($someCustomerGroupId);
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
$customerRepository->save($customer);

 

 

Cheers,

BX

Re: Add a customer to a group

Yeah I did this , $this->session->getCustomer()->setGroupId("5")->save(); and it worked , thanks