我创建了一个模块JuistdIT_CustomAttributeCustomer,以将自定义eav属性添加到客户实体。我使用addAttribute将功能添加到Setup / InstallData.php文件中。
$customerSetup->addAttribute(Customer::ENTITY, 'test_2', [
'type' => 'varchar',
'label' => 'Test 2',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
//"backend" => "",
//"source" => "",
"default" => "",
//"frontend" => "",
//"unique" => false,
//"note" => ""
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
'is_filterable_in_grid' => true,
'is_searchable_in_grid' => true,
]);
但是当我用以下方法卸载模块时
php bin/magento module:uninstall JuistdIT_CustomAttributeCustomer
我希望在卸载模块时删除所有添加的EAV属性。所以我添加了一个Setup / uninstal.php脚本,我想在其中使用removeAttribute函数:
$customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, "test_2");
但是ModuleDataSetupInterface在卸载时不可用,因此我无法使用:
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, "test_2");
有人可以帮我在“类Uninstall实现UninstallInterface”的卸载功能中使用removeAttribute函数
由于