Skip to content

I can’t get the data pack to show on admin panel

create a data patch to add a new attribute to the customer, for example when registering a new customer, in the admin panel it must be possible to view the new field (e.g.: Customer Code) and make the values ​​visible and add saving logic.

for now I created a datapach like this:

<?php
namespace AccentureCustomerAttributeSetupPatchData;

use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;
use MagentoCustomerModelCustomer;

class AddCustomerCode implements DataPatchInterface
{
    private $moduleDataSetup;
    private $eavSetupFactory;

    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }

    public function apply()
    {
        $this->moduleDataSetup->getConnection()->startSetup();
        
        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);

        $eavSetup->addAttribute(
            Customer::ENTITY,
            'customer_code',
            [
                'type' => 'varchar',
                'label' => 'Customer Code',
                'input' => 'text',
                'required' => false,
                'visible' => true,
                'user_defined' => true,
                'position' => 999,
                'system' => 0,
            ]
        );

        $attribute = $eavSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'customer_code');
        $attribute->setData(
            'used_in_forms',
            ['adminhtml_customer', 'customer_account_create', 'customer_account_edit']
        );
        $attribute->save();

        $this->moduleDataSetup->getConnection()->endSetup();
    }
    public static function getDependencies() {
        return [];
    }

    public function getAliases() {
        return [];
    }

}

but I can’t understand why it doesn’t come out