How to include the name of a module in Magento 2
To include the module name in Magento 2, you should use the following code:
                
			
			
		| 
					 1 2 3 4 5 6 7  | 
						public function __construct(    ..    \Magento\Framework\ObjectManagerInterface $objectManager,    .. ) {    $this->_objectManager = $objectManager; }  | 
					
then:
| 
					 1 2  | 
						$this->_objectManager->create('Magento\Sales\Model\Resource\Order\Invoice\Collection')    ->addAttributeToFilter('order_id', array('eq'=>$order->getId()))  | 
					
Alternatively, you can rely on another approach. Enter the following code
| 
					 1 2 3 4 5  | 
						public function __construct(    \Magento\Sales\Model\Resource\Order\Invoice\CollectionFactory $invoiceCollectionFactory ) {    $this->_invoiceCollectionFactory = $invoiceCollectionFactory; }  | 
					
then add this one
| 
					 1 2  | 
						$this->_invoiceCollectionFactory->create()        ->addAttributeToFilter('order_id', array('eq'=>$order->getId()));  | 
					
Source () ()
More tips from the Magento 2 Developers Cookbook
                
								
			
            







