Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace NameSpaceModuleConsoleCommand;
- use SymfonyComponentConsoleCommandCommand;
- use SymfonyComponentConsoleInputInputArgument;
- use MagentoFrameworkExceptionLocalizedException;
- use SymfonyComponentConsoleInputInputInterface;
- use SymfonyComponentConsoleOutputOutputInterface;
- class CustomCommandClass extends Command
- {
- public function __construct(
- MagentoFrameworkAppState $state,
- MagentoFrameworkObjectManagerInterface $objectManager,
- MagentoFrameworkObjectManagerConfigLoaderInterface $configLoader
- ) {
- $state->setAreaCode('frontend'); //SET CURRENT AREA
- $objectManager->configure($configLoader->load('frontend')); //SOLUTION
- parent::__construct();
- }
- }
- $objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $state = $objectManager->get('MagentoFrameworkAppState');
- $state->setAreaCode('frontend');
- $configLoader = $objectManager->create('MagentoFrameworkObjectManagerConfigLoaderInterface');
- $objectManager->configure($configLoader->load('frontend'));
Add Comment
Please, Sign In to add comment