1

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) ?

3

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();
0

I have tried this but it is showing fatal error Area code is not set . can you tell me how to deal with it?

Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Area code is not set in /var/www/html/magento22/vendor/magento/framework/App/State.php:152 Stack trace: #0 /var/www/html/magento22/vendor/magento/framework/Session/SessionManager.php(173): Magento\Framework\App\State->getAreaCode() #1 /var/www/html/magento22/generated/code/Magento/Framework/Session/Generic/Interceptor.php(50): Magento\Framework\Session\SessionManager->start() #2 /var/www/html/magento22/vendor/magento/framework/Session/SessionManager.php(130): Magento\Framework\Session\Generic\Interceptor->start() #3 /var/www/html/magento22/generated/code/Magento/Framework/Session/Generic/Interceptor.php(14): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framewor in /var/www/html/magento22/vendor/magento/framework/Session/SessionManager.php on line 175

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.