When I created one Customer Custom Attribute and changed its value website-wise from Admin-> Edit Customer Information so did not change it.
<?php
namespace Vendor\Extension\Setup\Patch\Data;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Customer\Model\Customer;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Customer\Setup\CustomerSetupFactory;
class AddCustomerStatusAttribute implements DataPatchInterface
{
private $moduleDataSetup;
private $customerSetupFactory;
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
CustomerSetupFactory $customerSetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->customerSetupFactory = $customerSetupFactory;
}
public function apply()
{
/** @var EavSetup $eavSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
$customerSetup->addAttribute(
Customer::ENTITY,
'customer_status',
[
'label' => 'Customer Approve',
'input' => 'select',
'required' => false,
'sort_order' => 40,
'visible' => true,
'system' => false,
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
'is_filterable_in_grid' => true,
'is_searchable_in_grid' => false,
'type' => 'int',
'default' => 1,
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
"note" => "Set Approve to login"
]
);
$attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'customer_status');
$used_in_forms[]="adminhtml_customer";
$attribute->setData('used_in_forms', $used_in_forms)
->setData("is_visible", 1)
->setData("sort_order", 100);
$attribute->save();
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}