Magento 2 error when saving client attributes

0

I create a client module this module works well, when I migrate data from mangenet 1.xa to magento 2.x with the tool migration tool and I want to create a new client not save the data does not show the data when I want to edit a user

<?php


namespace mimodulo\CustomerAttribute\Setup;

use Magento\Customer\Model\Customer;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
{
    private $customerSetupFactory;

    /**
     * Constructor
     *
     * @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
     */
    public function __construct(
        CustomerSetupFactory $customerSetupFactory
    ) {
        $this->customerSetupFactory = $customerSetupFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        $customerSetup->addAttribute('customer', 'tipo_de_documento', [
            'type' => 'varchar',
            'label' => 'Tipo de Documento',
            'input' => 'text',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'tipo_de_documento')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'telefono', [
            'type' => 'varchar',
            'label' => 'Telefono',
            'input' => 'text',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'telefono')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'send_customer_points_notificat', [
            'type' => 'int',
            'label' => 'send Customer Points Notification ',
            'input' => 'boolean',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'send_customer_points_notificat')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'notify_on_referral', [
            'type' => 'int',
            'label' => 'Notify on Referral',
            'input' => 'boolean',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'notify_on_referral')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'especializacion', [
            'type' => 'varchar',
            'label' => 'especializacion',
            'input' => 'text',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'especializacion')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'departamento', [
            'type' => 'varchar',
            'label' => 'Departamento',
            'input' => 'text',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'departamento')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();

        $customerSetup->addAttribute('customer', 'is_activated', [
            'type' => 'int',
            'label' => 'Is activated',
            'input' => 'boolean',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => '',
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'is_activated')
            ->addData(['used_in_forms' => [
                'adminhtml_customer',
                'adminhtml_checkout',
                'customer_account_create',
                'customer_account_edit',
            ]]);
        $attribute->save();
    }
}
    
asked by Daniel Rueda 06.12.2016 в 21:46
source

1 answer

0

In the following directory root / vendor / magento / data-migration-tool / etc / ce-to-ce / map-customer.xml.dist we create map-customer.xml

We create the fields that we ignore            

  customer_entity.cedula   

we do the data migration

in magento 2 we remove the data that we do not want

execution of queries to clear the data DELETE FROM customer_entity_varchar WHERE attribute_id in (attribute_id) DELETE FROM customer_entity_int WHERE attribute_id in (attribute_id)

After we delete the attributes of the main table

DELETE FROM eav_attribute WHERE attribute_id in (attribute_id)

    
answered by 09.12.2016 в 23:09