Using Model Factory
protected $_orderCollectionFactory;
public function __construct(
...
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
...
) {
...
$this->_orderCollectionFactory = $orderCollectionFactory;
...
}
public function getOrders() {
if (!$this->orders)
{
$this->orders = $this->_orderCollectionFactory->create()->addFieldToSelect('*');
}
return $this->orders;
}
Using Model
loading....
Using Repositories (Service Contracts)
loading....