1

This is my code:

        $values = ['value1','value2','value3'];
        $customer->setCustomAttribute('customer_attribute_code', $values);
        //\Magento\Customer\Api\CustomerRepositoryInterface
        $this->customerRepository->save($customer);

customer_attribute_code is a custom customer multiselect attribute. I'm trying to save all values from my arrray ($values), but it only save the first value: value1

Do you have any idea why ? I've also tried this format:

     $values[0] = 'value1';
     $values[1] = 'value2';

Thanks

1 Answer 1

1

By changing the code into this:

$customer->setCustomAttribute('customer_attribute_code','value1,value2');
$this->customerRepository->save($customer);

I've managed to save the custom customer multiselect attribute values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.