how can we use $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $tableName = $resource->getTableName('sales/order'); in magento2?

What is the replacement of core/resource in magento2? I have tried with \Magento\Framework\Setup\SchemaSetupInterface but its not instantiating in block or model classes.

1 Answer 1


\Magento\Framework\App\ResourceConnection is analog for 'core/resource' alias.

Pay attention on:

  • M2 don't have separation on read/write connection, so use $resource->getConnection('default');

  • M2 don't use aliases for table names, so use $resource->getTableName('sales_order');

  • not found any class \Magento\Framework\App\ResourceConnection Oct 14, 2015 at 9:09
  • sorry, for merchant beta is \Magento\Framework\App\Resource
    – KAndy
    Oct 14, 2015 at 9:13
  • Please let me know for developer beta Oct 14, 2015 at 9:15
  • for dev beta should be same as for merchant, but why you use so old version
    – KAndy
    Oct 14, 2015 at 9:16
  • what is the analog for core/store Feb 10, 2016 at 13:44

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.