I am trying to create custom attribute for customer , but it is not creating anything i cannot able to view in admin
here is my code
<?php
namespace TestHdSetup;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoEavSetupEavSetupFactory;
use MagentoEavModelAttributeRepository;
use MagentoCustomerModelCustomer;
use MagentoEavModelEntityAttributeScopedAttributeInterface;
class InstallData implements InstallDataInterface
{
/**
* @var CustomerSetupFactory
*/
protected $customerSetupFactory;
/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;
/**
* @var Config
*/
private $eavConfig;
/**
* @var
*/
private $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory, CustomerSetupFactory $customerSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
$customerSetup->addAttribute(Customer::ENTITY, 'fin_cus', [
'type' => 'varchar',
'label' => 'Fin customer',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'position' => 999,
'system' => 0,
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'fin_cus')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);
$attribute->save();
}
but i don’t find any custom attribute in admin created ,Kindly