1

I have products with variations (size, heel size... etc.) Every product has the same price for all variations. I want to remove the disabled attribute from price(it is called "pret" in the picture below) input in every situation.

price input is disabled:

enter image description here

Thank you.

0

If it's installed using InstallData, you can remove it also with UpgradeData

Try like this:

<?php

namespace MyVendor\MyModule\Setup;

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

class UpgradeData implements UpgradeDataInterface
{
    private $eavSetupFactory;

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

    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {

     $setup->startSetup();

     if (version_compare($context->getVersion(), '1.0.1', '<')) {
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
        $eavSetup->removeAttribute(
          \Magento\Catalog\Model\Product::ENTITY,
            'your_attribute');
     }

     $setup->endSetup();
    }
}  

Or you can also delete it directly in your Magento database under eav_attribute table.

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.