I added a custom product attribute to the default attribute set in Magento 2, but now when I try to remove it, by dragging the property to 'Unassigned Attributes' list, nothing happens. Its not clear how to remove a custom product attribute, once you added it to an attribute set.

I also tried this with a new custom product attribute set, added the custom attribute by dragging it to the Product Details group, saving the changes, and then trying to remove it again, but it does not seem to work.

I am using Magento 2.0.7.

  • 1
    Here is a screenshot showing the red cross when trying to remove an attribute: imgur.com/09wkJ88
    – omencat
    Jul 17 '16 at 22:50

You can remove it by adding the following code to the app/code/MyVendor/MyModule/Setup/InstallData.php file of your module (make sure to change the my_attribute value).


namespace MyVendor\MyModule\Setup;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class InstallData implements InstallDataInterface
    private $eavSetupFactory;

    public function __construct(EavSetupFactory $eavSetupFactory)
        $this->eavSetupFactory = $eavSetupFactory;

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

Hope it helps.

Purge cache and deploy static content by running the following commands.

php bin/magento cache:flush
php bin/magento setup:static-content:deploy -f

As a workaround, try dragging the unwanted attribute into the middle of the list instead of into the whitespace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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