Hi am working on a custom module that works based on custom product attribute. below is the code of installdata.php file
<?php
namespace VendorModuleSetup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* EAV setup factory
*
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
* Init
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(('setup' => $setup));
/**
* Add attributes to the eav/attribute
*/
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'no_free_shipping',
(
'group' => 'General',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'no_free_shipping',
'input' => 'boolean',
'class' => '',
'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '1',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => false,
'unique' => false,
'apply_to' => 'simple,configurable,bundle'
)
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'no_flat_rate',
(
'group' => 'General',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'no_flat_rate',
'input' => 'boolean',
'class' => '',
'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '1',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => false,
'unique' => false,
'apply_to' => 'simple,configurable,bundle'
)
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'no_table_rate',
(
'group' => 'General',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'no_table_rate',
'input' => 'boolean',
'class' => '',
'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '1',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => false,
'unique' => false,
'apply_to' => 'simple,configurable,bundle'
)
);
}
}
What i want is to remove/unassigned these attributes automatically when the magento module is removed or disable but unfortunately am not able to find a solution for this.
any suggestion please guide THANKS IN ADVANCE