0

How can delete all custom product attributes from database and keep only system attributes in Magento 2.4

2 Answers 2

1

You can acheive the same by Mysql query

DELETE FROM `eav_attribute` WHERE `eav_attribute`.`entity_type_id=4` AND `eav_attribute`.`is_user_defined`=1";

entity_type_id=4 for \Magento\Catalog\Model\Product::ENTITY

is_user_defined=1 means that that attribute is created by user and can be modified.

0

Try below script

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$eavSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, 'custom-attribute-code'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.