init
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Setup\Patch\Schema;
|
||||
|
||||
use Magento\Customer\Model\Customer;
|
||||
use Magento\Customer\Model\Indexer\Address\AttributeProvider;
|
||||
use Magento\Customer\Setup\CustomerSetup;
|
||||
use Magento\Customer\Setup\CustomerSetupFactory;
|
||||
use Magento\Eav\Model\AttributeRepository;
|
||||
use Magento\Eav\Model\Entity\Attribute\Set;
|
||||
use Magento\Eav\Model\Entity\Attribute\SetFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
use Magento\Framework\Validator\ValidateException;
|
||||
|
||||
class AddCustomerAbbrAttribute implements SchemaPatchInterface
|
||||
{
|
||||
/**
|
||||
* @var ModuleDataSetupInterface
|
||||
*/
|
||||
private $moduleDataSetup;
|
||||
/**
|
||||
* @var CustomerSetup
|
||||
*/
|
||||
private $customerSetupFactory;
|
||||
/**
|
||||
* @var SetFactory
|
||||
*/
|
||||
private $attributeSetFactory;
|
||||
private AttributeRepository $repository;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ModuleDataSetupInterface $moduleDataSetup
|
||||
* @param CustomerSetupFactory $customerSetupFactory
|
||||
* @param SetFactory $attributeSetFactory
|
||||
*/
|
||||
public function __construct(
|
||||
ModuleDataSetupInterface $moduleDataSetup,
|
||||
CustomerSetupFactory $customerSetupFactory,
|
||||
SetFactory $attributeSetFactory,
|
||||
AttributeRepository $repository
|
||||
) {
|
||||
$this->moduleDataSetup = $moduleDataSetup;
|
||||
$this->customerSetupFactory = $customerSetupFactory;
|
||||
$this->attributeSetFactory = $attributeSetFactory;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws LocalizedException
|
||||
* @throws ValidateException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->moduleDataSetup->getConnection()->startSetup();
|
||||
/** @var CustomerSetup $customerSetup */
|
||||
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
||||
|
||||
$customerSetup->addAttribute(Customer::ENTITY, 'customer_abbr', [
|
||||
'type' => 'varchar',
|
||||
'label' => 'Customer Abbr',
|
||||
'input' => 'text',
|
||||
'source' => '',
|
||||
'required' => true,
|
||||
'visible' => false,
|
||||
'position' => 330,
|
||||
'is_user_defined' => true,
|
||||
'is_used_in_grid' => true,
|
||||
]);
|
||||
|
||||
$this->moduleDataSetup->getConnection()->endSetup();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user