Found this error does not extend \Magento\Framework\DataObject
You did not define Model, Resource Model, Collection class properly. You have to define properly as below:
Model Class: app/code/Sugarcode/Test/Model/Fee.php
<?php
/**
* User: Amit Bera
* Email: [email protected]
*/
namespace Sugarcode\Test\Model;
class Fee extends \Magento\Framework\Model\AbstractModel
{
public function _construct()
{
$this->_init(\Sugarcode\Test\Model\ResourceModel\Fee::class);
}
}
Resource Model Class: app/code/Sugarcode/Test/Model/ResourceModel/Fee.php
<?php
/**
* User: Amit Bera
* Email: [email protected]
*/
namespace Sugarcode\Test\Model\ResourceModel;
class Fee extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Resource initialization
*
* @return void
*/
protected function _construct()
{
$this->_init('mr_dukaaniatest', 'dukaaniatest_id');
}
}
Collection Class: app/code/Sugarcode/Test/Model/ResourceModel/Fee/Collection.php
<?php
/**
* User: Amit Bera
* Email: [email protected]
*/
namespace Sugarcode\Test\Model\ResourceModel\Fee;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
public function _construct()
{
$this->_init(
\Sugarcode\Test\Model\Fee::class,
\Sugarcode\Test\Model\ResourceModel\Fee::class
);
}
}
I was facing the same issue On version 2.2.3 where is 2.2.2 work absolutely fine not sure but something change in 2.2.3 that the bellow does not accepts the use
:
...
use \Vendor\Module\Model\Entity;
use \Vendor\Module\Model\ResourceModel\Entity as EntityResourceModel;
...
$this->_init(Entity::class,EntityResourceModel::class);
...
2.2.3 version changing to :
$this->_init(
\Vendor\Module\Model\Entity::class,
\Vendor\Module\Model\ResourceModel\Entity::class
);
Works!