0

I created a new field on customer_entity table.

 $setup->getConnection()->addColumn(
            $setup->getTable('customer_entity'),
            'profession',
            [
                'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                'comment' => 'Profession',
                'nullable' => false,
                'default' => false,
            ]
        );

Now I need to update this field. I'm trying

    use Magento\Customer\Model\CustomerExtractor as CustomerExtractor;

    $customer = $this->customerExtractor->extract('customer_account_create', $this->_request);
    $customer->setCustomAttribute('profession','test');

but the field on table stay blank. No error appears.

2 Answers 2

0

I wrote a repo adding a new customer attribute that is public.

if you take a look you will see the attribute needs to be added to customers form as well as attribute set. Hope this repo gives you some ideas to resolve your issue

-1

Try below Code

use Magento\Customer\Model\CustomerExtractor as CustomerExtractor;

    $customer = $this->customerExtractor->extract('customer_account_create', $this->_request);
    $customer->setProfession('test');
    $customer->save();

I hope it help..!!!

3
  • this way i got a php error PHP Fatal error: Uncaught Error: Call to undefined method Magento\\Customer\\Model\\Data\\Customer::setProfession() in /var/www/html/saccaro/app/code/BVZ/Customer/Controller/Account/CreatePost.php:362\nStack trace:\n#0 Commented Dec 26, 2018 at 16:17
  • please add that error here. Commented Dec 26, 2018 at 16:18
  • [Wed Dec 26 14:17:06.359291 2018] [php7:error] [pid 11340] [client ::1:47130] PHP Fatal error: Uncaught Error: Call to undefined method Magento\\Customer\\Model\\Data\\Customer::setProfession() in /var/www/html/saccaro/app/code/BVZ/Customer/Controller/Account/CreatePost.php:362\nStack trace:\n#0 /var/www/html/saccaro/generated/code/BVZ/Customer/Controller/Account/CreatePost/Interceptor.php(24): BVZ\\Customer\\Controller\\Account\\CreatePost->execute()\n#1 Commented Dec 26, 2018 at 16:25

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.