1

I try to create EAV planner module. I am getting this error "Invalid entity_type specified: opco_planner_theme". All i want to understand why.

class Opco_Planner_Model_Resource_Theme
extends Mage_Eav_Model_Entity_Abstract
{
/**
 * Resource initialization
 */
public function __construct()
{
    $resource = Mage::getSingleton('core/resource');
    $this->setType('opco_planner_theme');
    $this->setConnection(
        $resource->getConnection('theme_read'),
        $resource->getConnection('theme_write')
    );
}

/*
 * Set default attributes
 */
 protected function _getDefaultAttributes()
 {
     return array(
        'entity_type_id',
        'attribute_set_id',
        'created_at',
        'updated_at',
        'increment_id',
        'store_id',
        'website_id'
     );
 }
}

and my setup class in resource folder opco/planner/model/resource/setup.php look like this

class Opco_Planner_Model_Resource_Setup
extends Mage_Eav_Model_Entity_Setup
{
/*
 * Setup attributes for inchoo_blog_post entity type
 * -this attributes will be saved in db if you set them
 */
public function getDefaultEntities()
{
    $entities = array(
        'opco_planner_theme' => array(
            'entity_model' => 'opco_planner/theme',
            'attribute_model' => '',
            'table' => 'opco_planner/theme_entity',
            'attributes' => array(
                'title' => array(
                    'type' => 'varchar',
                    'backend' => '',
                    'frontend' => '',
                    'label' => 'Title',
                    'input' => 'text',
                    'class' => '',
                    'source' => '',
                    'global' => 0,
                    'visible' => true,
                    'required' => true,
                    'user_defined' => true,
                    'default' => '',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => true,
                    'unique' => false,
                ),
                'author' => array(
                    'type' => 'varchar',
                    'backend' => '',
                    'frontend' => '',
                    'label' => 'Author',
                    'input' => 'text',
                    'class' => '',
                    'source' => '',
                    'global' => 0,
                    'visible' => true,
                    'required' => true,
                    'user_defined' => true,
                    'default' => '',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => false,
                    'unique' => false,
                ),
            ),
        )
    );
    return $entities;
}
}

"$this->setType('opco_planner_theme');" throw this exception does type should be match with some thing in config file my installer file look like this.

$installer = $this;
$installer->startSetup();

   /*
    * Create all entity tables
   */


 $installer->addEntityType('opco_planner_theme',Array(
   'entity_model'           => 'opco_planner/theme',
   'attribute_model'       => '',
   'table'                 => 'opco_planner/theme_entity',
   'increment_model'       => '',
   'increment_per_store'   => '0'
  ));

  $installer->createEntityTables(
     $this->getTable('opco_planner/theme_entity')
  );

  $installer->installEntities();

  $installer->endSetup();

My installer is responsible for insert entry in eav_entity_type table before my intaller file runs I get this error. config file iss

<config>
    <modules>
        <Opco_Planner>
            <version>1.0.0.0</version>
        </Opco_Planner>
    </modules>
    <global>
        <models>
            <opco_planner>
                <class>opco_planner_Model</class>
                <resourceModel>opco_planner_resource</resourceModel>
            </opco_planner>
            <opco_planner_resource>
                <class>opco_planner_Model_Resource</class>
                <entities>
                    <theme_entity>
                        <table>opco_planner_theme_entity</table>
                    </theme_entity>
                    <theme_entity_datetime>
                        <table>opco_planner_theme_entity_datetime</table>
                    </theme_entity_datetime>
                    <theme_entity_decimal>
                        <table>opco_planner_theme_entity_decimal</table>
                    </theme_entity_decimal>
                    <theme_entity_int>
                        <table>opco_planner_theme_entity_int</table>
                    </theme_entity_int>
                    <theme_entity_text>
                        <table>opco_planner_theme_entity_text</table>
                    </theme_entity_text>
                    <theme_entity_varchar>
                        <table>opco_planner_theme_entity_varchar</table>
                    </theme_entity_varchar>
                    <theme_entity_char>
                        <table>opco_planner_theme_entity_char</table>
                    </theme_entity_char>
                </entities>
            </opco_planner_resource>
        </models>
        <helpers>
            <opco_planner>
                <class>opco_planner_Helper</class>
            </opco_planner>
        </helpers>
        <blocks>
            <opco_planner>
                <class>opco_planner_Block</class>
            </opco_planner>
        </blocks>
        <resources>
            <opco_planner_setup>
                <setup>
                    <module>opco_planner</module>
                    <class>opco_planner_Model_Resource_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </opco_planner_setup>
            <theme_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </theme_write>
            <theme_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </theme_read>
        </resources>
    </global>
    <frontend>
        <routers>
            <opco_planner>
                <use>standard</use>
                <args>
                    <module>Opco_Planner</module>
                    <frontName>planner</frontName>
                </args>
            </opco_planner>
        </routers>
    </frontend>
</config>

Please help me understand where I am doing wrong. I know I make a mistake some where but I am unable to identify where.

Thanks

0 Answers0