What is the minimum configuration needed to build a custom module factory?
I have this and it is still not working:
table: custommodule_products which looks like:
| file_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| store_id | smallint(5) unsigned | NO | | NULL | |
| name | varchar(255) | NO | MUL | NULL | |
| logs | varchar(255) | NO | | NULL
//Example/Model/Example.php:
class Example extends AbstractModel
{
protected function _construct()
{
$this->_init("Vendor\Example\Model\ResourceModel\Example");
}
//Example/Model/ResourceModel/Example.php:
class Example extends AbstractDb
{
protected function _construct()
{
$this->_init('custommodule_products', 'file_id');
}
//Example/Model/ResourceModel/Example/Collection.php:
class Collection extends AbstractCollection
{
protected function _construct()
{
$this->_init(
'Vendor\Example\Model\Example',
'Vendor\Example\Model\ResourceModel\Example'
);
}
And then when I create my factory and try to save some data on a new row I get
Fatal error: Uncaught Error: Call to undefined method \Collection::setName()
:
use Vendor\Example\Model\ResourceModel\Example\CollectionFactory as FileFactory;
..constructor..
$newFileRow = $this->fileFactory->create();
$newFileRow->setName("test");
I don't understand what else does it need or how can I further debug it. I've checked var/generation/Module...CollectionFactory.php and the file is there. Does it need something else to be able to set data?
Thanks!