Magento 1 to Magento 2 Conversion – Mage::getModel(‘sales/order’) Migration

conversionmagento2

What is the class that is instantiated with command Mage::getModel('sales/order') in Magento 1 and what is the replacement of this class in Magento 2, ie. how can I get it with command $objectManager -> get($stringForGettingIt) ?

Best Answer

Mage::getModel('sales/order') is instantiated from

class Mage_Sales_Model_Order

You can achieve this in magento 2 from below code.

$objectManager = Magento\Framework\App\ObjectManager::getInstance();
$orders = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
Related Topic