2

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

0

Try following way:


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

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.