0

In Magento 1 when I wanted to delete a category attribute, I could delete theattribute directly in the database in the eav_attribute table. I've done that many times without any problems.

Can I safely delete my custom category attributes this way also in Magento 2?

The table eav_attribute still exists, but there are also other tables with similar names. Would I also need to delete my attribute from other tables, or eav_attribute is enough? And is it safe to delete the attribute directly from the database in Magento 2?

1
  • 1
    yes you can delete directly from database same as magento 1. but would be prefer to use script to delete entry. Jan 4, 2017 at 11:44

2 Answers 2

3

Yes. deleting the attribute from eav_attribute does not created issue .

It does not create an issue.

-2

If you try to delete category attribute programmatically then it will delete all attribute entry from all tables,

better then directly remove from table, you can follow below url

Remove category attribute

Or you can follow below code,

<?php

require_once('app/Mage.php');
Mage::app('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$setup          = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId   = $setup->getEntityTypeId('catalog_category');
$attributeCode  = 'extra_activities';

$setup->removeAttribute($entityTypeId, $attributeCode);

?>

1
  • 1
    Thank you, but your answer is for Magento 1, not for Magento 2.
    – zitix
    Jan 5, 2017 at 15:25

Your Answer

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

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