I have a class

$class = new Abc\Cde\Efg('variable');

how can i implement this using object manager

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$class = $objectManager->create(Abc\Cde\Efg);

The variable value is required. Right now i have only one option to use new. but i dont want to use new keyword in magento2

1 Answer 1


Try following way:

$class = $objectManager->create('Abc\Cde\Efg', ['Variable']);
  • not working, it is still throwing error. Exception #0 (BadMethodCallException): Missing required argument Commented Sep 22, 2018 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.