I am little bit confuse, how to use object manager. I have checked this answer but not getting satisfied answer.
Always we are recommending that never use objectManager like \Magento\Framework\App\ObjectManager::getInstance()
.
Instead of use this :
public function __construct(
...
\Magento\Framework\ObjectManagerInterface $objectmanager,
...
)
{
...
$this->_objectManager = $objectmanager;
...
}
But when we are using this in any plugin file or any custom module file, we are getting error or its not working. But in case of direct method we are getting solution.
Is there any proper definition, where we have to use direct method of objectManager
and where we have to use ObjectManagerInterface
?
Actually when I am trying to get objectManager object in my custom module file I am getting some error and its not working. and with the help of direct method getting proper solution.