2

I have created a command for my module which calls a class Model/Importer from https://github.com/firegento/FireGento_FastSimpleImport2 extension. but i think it requires admin session.

I have tried to add area code by referring to this question 'Area code not set' issue in custom CLI commands in Magento 2

But still after clearing everything from var folder, i am getting the same exception.

1

1 Answer 1

3
#File: vendor/magento/framework/App/State.php

If you debug the above file,Magento\Framework\App\State object will only let you set a value once. As you know a command line scripts has no area.

Below code should pass the Area code not set exceptions.

When I was trying for the same, I did get the below working code from somewhere. It was working for me few days ago.

  public function __construct(
    \Magento\Framework\App\State $appState,
    $name=null
)
{
    $appState->setAreaCode('frontend');
    parent::__construct($name);
}

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.