1

We have a custom console command and it was working fine in Magento 2.2.7 , when we move this extension to Magento 2.3 it failed when we running setup:upgrade.

Anyone who have faced exact similar issue. Please do help.

  • 1
    how is your command declared in di.xml? – Marius Mar 8 at 11:58
2

Add this to the di.xml file

<type name="Vendor\ModuleName\Command\OrderQueue">
    <arguments>
        <argument name="state" xsi:type="object">Magento\Framework\App\State\Proxy</argument>
        <argument name="orderCron" xsi:type="object">Vendor\ModuleName\Order\Proxy</argument>
    </arguments>
</type>

you can also remove $this->state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND); from the configure method

  • Sorry. fixed the typo – Marius Mar 8 at 12:19
  • Please explain to me why this change and even in devdocs has nothing seems changed and more than anything how did you got these information I mean this method is working in 2.3. Please take time and give me some learning :) – Prathap Gunasekaran Mar 8 at 12:26
  • You're simple terrific mate :) @marius – Prathap Gunasekaran Mar 8 at 12:26
  • 1
    some of your dependencies or the dependencies of depencencies try to start the session and there is no area code when that happens. The solution is to provide proxy classes as dependencies so nothing else gets instantiated until it is needed. – Marius Mar 8 at 12:43

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.