use Magento\Framework\App\ObjectManager; $objectManager = ObjectManager::getInstance(); $myModel = $objectManager->create('Vendor\Module\Model\MyModel');
use Magento\Framework\App\ObjectManager; $objectManager = ObjectManager::getInstance(); $myBlock = $objectManager->get('Vendor\Module\Block\MyBlock');This code uses the get() method of the ObjectManagerInterface to get an instance of a block class, Vendor\Module\Block\MyBlock. Once again, this is just an example class and would need to be replaced with a real class name. The package library for this code is Magento\Framework\App\ObjectManager.