How do I add a customer to a group programatically in magento2
Solved! Go to Solution.
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);
Yeah I did this , $this->session->getCustomer()->setGroupId("5")->save(); and it worked , thanks