Fatal error: Uncaught Error: Call to undefined method Magento\Framework\App\ResourceConnection::load() in /var/www/html/magento2_dev/vendor/magento/framework/Model/AbstractModel.php:536
Just adding the resource connection on my extended Sales Model, getting the above issue.
Below is my code:
<?php
namespace Sdi\Sales\Model;
use Magento\Framework\App\Request\DataPersistorInterface;
class Order extends \Magento\Sales\Model\Order
{
protected $_resource;
public function __construct(
\Magento\Framework\App\ResourceConnection $resource
) {
$this->_resource = $resource;
}
public function bnDelete()
{
if ($this->getStatus() == Mage_Sales_Model_Order::STATE_CANCELED) {
$connection = $this->_resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
$query = 'SQL QUERY';
$connection->query($query);
}
return false;
}
}