ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Lts\Customer\Setup\Patch\Data;
|
||||
|
||||
use Magento\Customer\Model\Customer;
|
||||
use Magento\Customer\Setup\CustomerSetup;
|
||||
use Magento\Customer\Setup\CustomerSetupFactory;
|
||||
use Magento\Eav\Model\Entity\Attribute\Set;
|
||||
use Magento\Eav\Model\Entity\Attribute\SetFactory;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
||||
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
|
||||
|
||||
class AddIsNetsuiteSyncCustomerAttribute implements DataPatchInterface, PatchRevertableInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ModuleDataSetupInterface $moduleDataSetup
|
||||
* @param CustomerSetupFactory $customerSetupFactory
|
||||
* @param SetFactory $attributeSetFactory
|
||||
*/
|
||||
public function __construct(
|
||||
private ModuleDataSetupInterface $moduleDataSetup,
|
||||
private CustomerSetupFactory $customerSetupFactory,
|
||||
private SetFactory $attributeSetFactory
|
||||
) {
|
||||
$this->moduleDataSetup = $moduleDataSetup;
|
||||
$this->customerSetupFactory = $customerSetupFactory;
|
||||
$this->attributeSetFactory = $attributeSetFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
* @throws \Magento\Framework\Validator\ValidateException
|
||||
*/
|
||||
public function apply(): void
|
||||
{
|
||||
$this->moduleDataSetup->getConnection()->startSetup();
|
||||
/** @var CustomerSetup $customerSetup */
|
||||
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
||||
|
||||
$customerSetup->addAttribute(
|
||||
Customer::ENTITY,
|
||||
'is_netsuite_sync',
|
||||
[
|
||||
'label' => 'is synced to Netsuite',
|
||||
'input' => 'boolean',
|
||||
'type' => 'static',
|
||||
'source' => '',
|
||||
'required' => false,
|
||||
'position' => 333,
|
||||
'visible' => false,
|
||||
'system' => false,
|
||||
'backend' => ''
|
||||
]
|
||||
);
|
||||
|
||||
$this->moduleDataSetup->getConnection()->endSetup();
|
||||
}
|
||||
|
||||
public function revert(): void
|
||||
{
|
||||
$this->moduleDataSetup->getConnection()->startSetup();
|
||||
/** @var CustomerSetup $customerSetup */
|
||||
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
||||
$customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, 'is_netsuite_sync');
|
||||
|
||||
$this->moduleDataSetup->getConnection()->endSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAliases(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getDependencies(): array
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user