0

Hi I am trying to remove the category attribute using Uninstall script but it is not working. Here is my code. Setup\Uninstall.php

 <?php

namespace Company\Module\Setup;

use Magento\Eav\Setup\EavSetupFactory;

use Magento\Framework\Setup\UninstallInterface;

use Magento\Framework\Setup\SchemaSetupInterface;

use Magento\Framework\Setup\ModuleContextInterface;

class Uninstall implements UninstallInterface
{

    protected $eavSetupFactory;

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

    public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        $eavSetup = $this->eavSetupFactory->create();

        $entityTypeId = 3; 
//        $entityTypeId = \Magento\Catalog\Model\Category::ENTITY;

        if (version_compare($context->getVersion(), '1.0.4') < 0) {
            $eavSetup->removeAttribute($entityTypeId, 'test_input_field');
        }

        $setup->endSetup();

    }
}

Any help appreciated.

3
  • You are using php bin/magento module:uninstall command? – Dominic Xigen Jun 10 '19 at 13:33
  • no I am using upgrade command, Also I need to mention the module name in the command. – Nitin Pawar Jun 10 '19 at 13:35
  • As far as I'm aware this would only be triggered by something like this magento module:uninstall Magento_SampleMinimal – Dominic Xigen Jun 10 '19 at 13:39
0

Replace This Line :-

From :-

$eavSetup = $this->eavSetupFactory->create();

To :-

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
2
  • Will try this, which command should i use. – Nitin Pawar Jun 10 '19 at 13:36
  • in your script just replace this line – Rk Rathod Jun 10 '19 at 13:37

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.