Guest User

Untitled

a guest
Dec 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. namespace NameSpaceModuleConsoleCommand;
  3.  
  4. use SymfonyComponentConsoleCommandCommand;
  5. use SymfonyComponentConsoleInputInputArgument;
  6. use MagentoFrameworkExceptionLocalizedException;
  7. use SymfonyComponentConsoleInputInputInterface;
  8. use SymfonyComponentConsoleOutputOutputInterface;
  9.  
  10. class CustomCommandClass extends Command
  11. {
  12. public function __construct(
  13. MagentoFrameworkAppState $state,
  14. MagentoFrameworkObjectManagerInterface $objectManager,
  15. MagentoFrameworkObjectManagerConfigLoaderInterface $configLoader
  16. ) {
  17. $state->setAreaCode('frontend'); //SET CURRENT AREA
  18. $objectManager->configure($configLoader->load('frontend')); //SOLUTION
  19. parent::__construct();
  20. }
  21. }
  22.  
  23. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  24. $state = $objectManager->get('MagentoFrameworkAppState');
  25. $state->setAreaCode('frontend');
  26. $configLoader = $objectManager->create('MagentoFrameworkObjectManagerConfigLoaderInterface');
  27. $objectManager->configure($configLoader->load('frontend'));
Add Comment
Please, Sign In to add comment