1

I made setted up a custom model but I'm stuck on getCollection methods which results in Invalid entity supplied

My setup:

IndexController.php

Mage::getModel('custom/customerobject')->getCollection();
// this is where the error happens

Resource/Customeobject/Collection.php

class Unreal_Custom_Model_Resource_Customerobject_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
    /**
     * Resource initialization
     */
    protected function _construct()
    {
        $this->_init('custom/customerobject');
    }

}

config.xml

  <models>
        <custom>
            <class>Unreal_Custom_Model</class>
            <resourceModel>unreal_resource</resourceModel>
        </custom>
        <unreal_resource>
            <class>Unreal_Custom_Model_Resource</class>
            <entities>
                <statusobject> 
                    <table>statusobject</table>
                </statusobject>
            </entities>
            <entities>
                <customerobject> 
                    <table>customerobject</table>
                </customerobject>
            </entities>
        </unreal_resource>
    </models>

sql script used to create table

if(!$installer->getConnection()->isTableExists($installer->getTable('custom/customerobject')))
{
    $customerObjectTable = $installer->getConnection()->newTable($installer->getTable('custom/customerobject'))
    ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
            'unsigned' => true,
            'nullable' => false,
            'primary' => true,
            'identity' => true,
            ), 'ID')
        ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
            'nullable' => false,
            ), 'Email')
        ->addColumn('password', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
            'nullable' => true,
            ), 'Password')
        ->addColumn('firstname', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
            'nullable' => false,
            ), 'FirstName')
                ->addColumn('lastname', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
            'nullable' => false,
            ), 'LastName');
    $installer->getConnection()->createTable($customerObjectTable);
} 

Please help me out here because I have no idea where to start

Thanks

1 Answer 1

2

It seems that the Collection.php should extend from Mage_Core_Model_Resource_Db_Collection_Abstract insteadof Mage_Eav_Model_Entity_Collection_Abstract

1
  • Feel free to mark your own answer as solution. Jan 31, 2016 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.