From this website:
Manually Load Object Manager
You should avoid calling the object manager directly as this is not the proper way, but if you have to you use:
$om = \Magento\Framework\App\ObjectManager::getInstance(); /* use object manager to get a class for example the attribute repository */ $attr = $om->get('\Magento\Eav\Api\AttributeRepositoryInterface'); /* use returned class attribute repository to get the attribute id of the name for products */ $productNameAttributeId = $attr->get('catalog_product', 'name')->getId();
this is not proper way, but if you have to you use
How can I do this the proper way?