0

I've created custom customer attribues

        $attributeCodes = [
            ['code' => 'customer_company' , 'label'=> 'Societe'],
            ['code' => 'customer_siret', 'label'=> 'Siret'],
            ['code' => 'customer_forme_juridique','label' => 'Forme Juridique'],
            ['code' => 'customer_tva', 'label' => 'TVA']
        ];
        foreach ($attributeCodes as $attr){
            $attributeCode = $attr['code'];
            $attributeLabel = $attr['label'];
            $eavSetup->addAttribute(
                Customer::ENTITY,
                $attributeCode,
                [
                    'type'         => 'varchar',
                    'label'        => $attributeLabel,
                    'input'        => 'text',
                    'required'     => false,
                    'visible'      => true,
                    'user_defined' => true,
                    'position'     => 999,
                    'system'       => 0,
                ]
            );
            $attribute = $this->eavConfig->getAttribute(Customer::ENTITY, $attributeCode);
            $attribute->setData(
                'used_in_forms',
                ['adminhtml_customer','customer_account_edit']

            );
            $attribute->save();
        }

THey are now appearing in the customer edit form.

But when I save them, I don't see any values saved in customer_entity_varchar for any of these attributes

That being said if i'm going to magento 2 core code : src/vendor/magento/module-customer/Controller/Adminhtml/Index/Save.php and dumping there

            $customerData = $this->_extractCustomerData();
            var_dump($customerData);

At this point the total is in the customerData so I don't get why she isn't saved after all (I don't have any error message neither).

What am I missing there ?

1 Answer 1

0

you can take reference from this url

https://www.mageplaza.com/magento-2-module-development/magento-2-add-customer-attribute-programmatically.html

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.