Solved: How to fix ‘Class Magento\Sales\Model\Resource\Order\Collection does not exist’


I recently upgraded my Magento installation from Magento 2.0 to Magento 2.1 and everything was fine until I ran ‘php magento setup:di:compile’ command after ‘php magento setup:upgrade’. I was instantly served with a big red error on my SSH tunnel.

After spending hours and hours on trying to fix the issue, I realized that the extension which I created to integrate ZENDESK Chat with Magento 2 contains an outdated Class name. Just so you know – In order to support PHP 7, where “Resource” is a reserved word, Resource namespace was renamed to ResourceModel long time ago. Therefore, it Resource cannot be used as a namespace anymore.

After I fixed the issue, my extension started to work fine and hopefully, you will be able to apply a quick fix by replacing all occurrences of Magento\Sales\Model\Resource\Order to Magento\Sales\Model\ResourceModel\Order

Please leave a comment and let me know if you are still not able to fix the error.